I'm trying to control where jobs are run from a groovy script, it's an edge case that I have to run on all nodes in a label rather than what's free. I was hoping I could use the nodelabel plugin to do this.
On my slave job I have a label parameter, named and defaults to my label that a lot of slaves are hooked up to (Distributed_build), I run as run on all nodes matching the label, ignore offline nodes and run regardless of result.
I put a machine in there that's part of the label cluster to see if I could force to a node (Machine_1) so I could visually see the jobs queued for that node rather than using a free node part of the label cluster, but it seems to run all builds on the label cluster regardless. Am I doing something wrong or just assuming incorrectly how the plugin works?
In my source job I have the following groovy script.
def nodes = [
"Distributed_build",
"Distributed_build",
"Distributed_build",
"Distributed_build",
"Distributed_build",
"Machine_1",
"Machine_1",
"Machine_1",
"Machine_1"
];
def targetJobName = "SuperDuper Job"
def jobToTrigger = Jenkins.instance.getItem( targetJobName )
def i=1
nodes.each {
node ->
if(jobToTrigger!=null) {
def futureJob = jobToTrigger.scheduleBuild( 2, new Cause.UpstreamCause( build ), new ParametersAction( [
new StringParameterValue( 'Distribution_Label', node ),
new StringParameterValue( 'Build_Command_Line', i.toString() )
] ) )
println(futureJob)
}
println(node)
i++
}