eerriicc
eerriicc

Reputation: 1240

How can I ensure that only one if a kind of Jenkins job is run?

I have several integration tests within my Jenkins jobs. They run on several application servers, and I want to make sure that only one integration test job is run at the same time on one application server.

I would need something like a tag or variable within my jobs which create a group of jobs and then configure the logic that within that group, only one job may run at the same time.

Could I use the Exclusion plugin for that? Does anyone have experience with it?

Upvotes: 8

Views: 14421

Answers (3)

Jman91
Jman91

Reputation: 31

Did you check below parameter in the Jenkins -> Manage Jenkins -> Configure system

# of executors

The above parameter helps you restrict the number of jobs to be executed at a time.

A Jenkins executor is one of the basic building blocks which allow a build to run on a node/agent (e.g. build server). Think of an executor as a single “process ID”, or as the basic unit of resource that Jenkins executes on your machine to run a build. Please see Jenkins Terminology for more details regarding executors, nodes/agents, as well as other foundational pieces of Jenkins.

You can find information on how to set the number of Jenkins executors for a given agent on the Remoting Best Practices page, section Number of executors. Source - https://support.cloudbees.com/hc/en-us/articles/216456477-What-is-a-Jenkins-Executor-and-how-can-I-best-utilize-my-executors

Upvotes: 0

mc1arke
mc1arke

Reputation: 1060

Use the Throttle Concurrent Builds Plugin. It replaces the Locks and Latches plugin, and provides the capability to restrict the number of jobs running for specific labels.

For example: you create a project category 'Integration Test Server A' and tie jobs to it with a maximum concurrent count of 1, and a second 'Integration Test Server B' label and tie other jobs to it, both categories will only run a single concurrent build (assuming you've set a max job count of 1), and the other jobs in that category will queue until the 'lock' has cleared.

Using this method, you don't have to restrict the number of executors available on any specific Jenkins instance, and can easily add further slaves in the future without having to reconfigure all your jobs.

Upvotes: 13

Peter Schuetze
Peter Schuetze

Reputation: 16305

If I understand you right, you have a pool of application servers and it doesn't matter on what server your tests run. They only need to be the only test on that server.

I haven't seen a plugin that can do that. However, you can get easily around it. You need to configure a slave for each application server. (1 slave = 1 app server) You need to assign the same label to all slaves and every slave can only have one executor. Then you assign the jobs that run the integration tests, to run on that label. Jenkins will assign the jobs then to the next available slave (or node) that has that label.

Bare in mind that you can have more than one slave running on the same piece of hardware and even a master and a slave can coexist on the same server.

Upvotes: 0

Related Questions