Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins to not allow the same job to run concurrently on the same node?

Tags:

jenkins

I have 4 nodes and 2 jobs. Any node can run 2 jobs concurrently and any job can be executed concurrently. I want to be able to restrict running the same job concurrently on the same machine. For example:

Jobs: J1 and J2 nodes: N1,N2,N3 and N4

I can run J1 and J2 on the same node at the same time. I can run J1 on N1 and N3 at the same time. BUT I do not want to run J1 and another build of J1 on the same node at the same time.

I have tried "Locks and Latches", "Jenkins Exclusive Execution", "Exclusion Plugin" plugins, and these will work well when trying to coordinate different jobs. But my case is trying to manage different build-instances of the same job.

like image 753
Marek Gimza Avatar asked Jun 22 '12 14:06

Marek Gimza


People also ask

How can you prevent two Jenkins from running in parallel?

Create a lock and have both jobs use the same lock. That will prevent the jobs from running concurrently.

How do I stop concurrent builds in Jenkins?

Disable concurrent builds in Jenkins declarative pipeline. Define disableConcurrentBuilds option to disallow concurrent executions.

Can a single Jenkins job run on multiple nodes True or false?

Step 1− If multi node selection was enabled, you get the chance to select multiple nodes to run the job on. The job will then be executed on each of the nodes, one after the other or concurrent - depending on the configuration.

Which parameter decides how many concurrent jobs you can run on your Jenkins *?

The maximum number of Jenkins jobs is dependent upon what you set as the limits in the master and slaves. Usually, we limit by the number of cores, but your mileage may vary depending upon available memory, disk speed, availability of SSD, and overlap of source code.


1 Answers

Try Throttle Concurrent Builds Plugin. It allows to throtte the number of concurrent builds of a project running per node or globally. In your case you should set:

  • Maximum Total Concurrent Builds: 0 (= unlimited)
  • Maximum Concurrent Builds Per Node: 1
like image 198
Draco Ater Avatar answered Oct 13 '22 20:10

Draco Ater