In my case, I have a pipeline called setup-upstream to select 4 nodes with the sim-test label and changes to reserved-sim-test-{buildnumber} then trigger the downstream job to call the individual node to run some steps then change its label to sim-test-pre-{buildnumber} if successful.
So the issue is that after sim-test changed to reserved-sim-test-{buildnumber}using:
- def node = Jenkins.instance.getNode({node_name});
- node.setLabelString("reserved-sim-test-{buildnumber}");
- node.save();
I can still access the node by Original label: `{JENKINS_URL}/label/sim-test/ ` and new label: `{JENKINS_URL}/label/reserved-sim-test-{buildnumber}/` from api in a short time.
SomeTests:
Pipeline:
def node = Jenkins.instance.getNode("36.23")
println("Origin lable:"+node.getLabelString())
node.setLabelString("roger")
node.save()
println("New lable:"+node.getLabelString())
def nodes = Jenkins.instance.getLabel("roger").getNodes()
println(nodes)
def nodes2 = Jenkins.instance.getLabel("roger2").getNodes()
println(nodes2)
Output:
10:12:34 Started by user
roger
10:12:34 Replayed
#177
10:12:34 [Pipeline] Start of Pipeline hide
10:12:34 [Pipeline] echo
10:12:34 Origin lable:roger2
10:12:34 [Pipeline] echo
10:12:34 New lable:roger
10:12:34 [Pipeline] echo
10:12:34 [hudson.slaves.DumbSlave[36.23]]
10:12:34 [Pipeline] echo
10:12:34 [hudson.slaves.DumbSlave[36.23]]
10:12:34 [Pipeline] End of Pipeline
10:12:34 Finished: SUCCESS