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.
Create a lock and have both jobs use the same lock. That will prevent the jobs from running concurrently.
Disable concurrent builds in Jenkins declarative pipeline. Define disableConcurrentBuilds option to disallow concurrent executions.
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.
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With