How to limit Jenkins concurrent multibranch pipeline builds across branches?

Viewed 1410

Does anybody have an idea how to limit concurrent builds with a declarative pipeline set up in a multibranch job across branches?

Anytime we set an agent for a stage, a new executor will be allocated. This leads to deadlocks e.g. when you have builds triggered concurrently for as many branches as you have executors. Not setting an agent leads to the stage chosing an executor randomly, which isn't acceptable as certain stages need to run on certain agents...

The classic approaches don't work:

  • Throttle Concurrent Builds Plugin doesn't work with multibranch
  • Setting properties([disableConcurrentBuilds()]) just limits concurrency per branch
  • the lock step needs agent none in the pipeline root to prevent allocating executors, but this hinders our global post block to execute suff as it needs an agent and apparently one cannot set an agent for the post block
1 Answers
Related