[英]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: 我对Jenkins很新,需要您对以下Jenkins用例的意见:
Scenario: We have 3 slaves which are selected as part of the "Node" parameter for the build. 场景:我们有3个从属选择作为构建的“Node”参数的一部分。 Each slave can and should execute only one build at a time [So, no. 每个奴隶可以而且应该一次只执行一次构建[所以,不。 of executors per node is set to 1]. 每个节点的执行程序设置为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. 我尝试使用默认的Jenkins负载均衡器和最小负载插件,但没有观察到任何差异。 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 谢谢,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. 使该标签表达式与所有三个从属节点匹配,然后Jenkins将选择一个空闲节点来执行您的作业。
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. 例如,您可以将每个从属标记为“构建器”,然后使用标签表达式“构建器”让Jenkins选择一个标记为奴隶的“构建器”作为托管该作业的从属。
Or, you could insert the names of the 3 slaves into the label expression (machine1 || machine2 || machine3). 或者,您可以将3个从属的名称插入到标签表达式(machine1 || machine2 || machine3)中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.