Mads Opheim
Mads Opheim

Reputation: 41

Jenkins: Run only one build for a job on each node

We have a project where we have several Jenkins jobs: One type of jobs that runs delivery (A),

one that does just compilation and unit tests (B)

and

one that runs integration tests, static code analysis et cetera (C).

We run on four Jenkins nodes (master + three slaves), and our jobs are a mix of declarative pipeline jobs and manually clicked in Jenkins-jobs.

We only want to run one integration test build per node at a time. However, we want to run as many deliveries (A) and code quality (B) builds as there are executors.

Until now, the Throttle concurrent builds (https://github.com/jenkinsci/throttle-concurrent-builds-plugin) plugin has satisfied our needs. However, this plugin does not support declarative pipeline builds, nor does it at all seem updated.

The Lockable resources plugin (https://github.com/jenkinsci/lockable-resources-plugin) seems promising, but we haven't found any way to lock the entire build with a resource-name dynamically set. That is, when we start a C build, we want it to lock "resource_{name of server}". This plugin allows setting an entire-build-lock in the options directive, נut we haven't figured out how to evaluate an environment variable there.

Any suggestions would be highly appreciated!

Upvotes: 2

Views: 2848

Answers (1)

Mads Opheim
Mads Opheim

Reputation: 41

So the workaround on our side was to rewrite the pipeline script from declarative to scripted syntax. Then, the throttle concurrent builds-plugin works as a charm.

When the bug https://issues.jenkins-ci.org/browse/JENKINS-49173 is fixed, the plugin will work with declarative pipelines as well.

Upvotes: 2

Related Questions