1

Say I have Jenkins Job "abc_job" which calls another jenkins job "xyz_job" depending on certain conditions.

Now for some reasons, both of the jobs are suppose to run on the same jenkins slave which results in a deadlock condition as job "abc_job" has triggered "xyz_job" and "xyz_job" is waiting for "abc_job" to release jenkins slave for it to start working.

How do you overcome such a scenario?

1 Answers1

0

There are three ways around this that I'm aware of and that I've used in the past. Which one is best depends on your particular situation.

  • Add more executor slots. You can also get fancy with executor labels and restricting builds to certain labels to ensure there's always a free executor slot for your downstream job, but this is tricky to get right.
  • Don't wait for the downstream job to finish. Run the build with build(wait: false, job: ...). The parent job will exit immediately instead of consuming an executor slot while it waits for downstream. This has the consequence that parent build won't fail if the downstream build fails.
  • Do not call build() inside of a node { } block. Code outside of a node block is executed on the master and does not consume an executor slot. However I believe this is only possible if you are using Scripted Pipeline, not Declarative.
jayhendren
  • 917
  • 4
  • 11