I have Jenkins declarative pipelines for a few different repos that trigger a database refresh, and unit tests that depend on the database. These Jenkins jobs are triggered from pull requests in GitHub.
To avoid resource collisions, I need to prevent these jobs from running at the same time -- both within each project, and across projects.
The "Throttle Concurrent Builds" plugin seems to be built for this.
I have installed the plugin and configured a category like so:
And I added the "throttle" option to the Jenkinsfile in one of the repositories whose builds should be throttled:
pipeline {
agent any
options {
throttle(['ci_database_build'])
}
stages {
stage('Build') {
parallel {
stage('Build source') {
steps {
// etc etc...
However, this does not seem to be preventing 2 jobs from executing at once. As evidence, here are 2 jobs (both containing the above Jenkisfile change) executing at the same time:
What am I missing?
The following in the options block should work
options {
throttleJobProperty(
categories: ['ci_database_build'],
throttleEnabled: true,
throttleOption: 'category',
)
}
The full syntax can be seen here: https://github.com/jenkinsci/throttle-concurrent-builds-plugin/pull/68)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With