Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent certain Jenkins jobs from running simultaneously?

Tags:

jenkins

hudson

I have a couple of jobs that use a shared resource (database), which sometimes can cause builds to fail in the (rare) event that the jobs happen to get triggered simultaneously.

Given jobs A through E, for example, is there any way to specify that A and C should never be run concurrently?

Other than the aforementioned resource, the builds are independent of each other (not e.g. in a upstream/downstream relation).

A "brute-force" way would be limiting number of executors to one, but that obviously is less than ideal if most jobs could well be executed concurrently and there's no lack of computing resources on the build server.

like image 509
Jonik Avatar asked Jun 08 '11 08:06

Jonik


People also ask

How can you prevent two Jenkins from running in parallel?

The Locks and Latches plugin should resolve your problem. Create a lock and have both jobs use the same lock. That will prevent the jobs from running concurrently. Install the plugin in "Manage Jenkins: Manage Plugins."

How can you prevent from several pipeline jobs of the same type to run in parallel on the same node?

Show activity on this post. Install Jenkins Lockable Resources Plugin. In your pipeline script wrap the part in the lock block and give this lockable resource a name. Use the name of whatever resource you are locking.

How do I stop a Jenkins job from running?

Abort the job by clicking the red X next to the build progress bar. Click on "Pause/resume" on the build to pause. Click on "Pause/resume" again to resume the build.


2 Answers

There are currently 2 ways of doing this:

  • Use the Throttle Concurrent Builds plugin.
  • Set up those jobs to run on a slave having only 1 executor.
like image 144
sti Avatar answered Oct 14 '22 00:10

sti


The Locks and Latches plugin here should help.

This question is probably a dupe of How do I ensure that only one of a certain category of job runs at once in Hudson?

like image 29
pwan Avatar answered Oct 13 '22 23:10

pwan