简体   繁体   中英

How to ensure that a build selects an idle Jenkins slave from the Node parameter?

I am pretty new to Jenkins and need your opinion on the below Jenkins use case:

Scenario: We have 3 slaves which are selected as part of the "Node" parameter for the build. Each slave can and should execute only one build at a time [So, no. of executors per node is set to 1]. When a build is started, the build should automatically select an idle slave to execute the job. Please provide inputs on how this can be achieved.

I tried using the default Jenkins load balancer and the Least Load plugin, but did not observe any difference. Whenever I initiate the build, the first node selected in the "Node" parameter gets selected, by default.

Please let me know how this can be accomplished.

Thanks, Praveen

When you parameterize a build with a node parameter, that requires the user that started the job to select the node which will execute the job. The user is probably not well equipped to choose a node which is not busy.

You could instead use the "Advanced" section of the job definition and "restrict where this project can be run". That field allows you to define a label expression which will select the nodes allowed to run the job. Make that label expression match all three of your slave nodes, and then Jenkins will select one of the idle nodes to execute your job.

For instance, you could label each of your slaves as "builder", then use the label expression "builder" to have Jenkins select one of the "builder" labeled slaves as the slave to host that job.

Or, you could insert the names of the 3 slaves into the label expression (machine1 || machine2 || machine3).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM