Note: the other answers are a bit outdated, so it is possible that the API has appeared since then.
Node Shortcuts are accessed in the API as a single line, as on the Configuration screen.
To read and write labels: Node.getLabelString () and Node.setLabelString (String) .
Note that you can also get effective labels: Node.getAssignedLabels () , which returns a LabelAtom collection that includes dynamically calculated labels, such as "self-adhesive" (representing the name itself node).
Finally, these methods in the Node class are accessible directly from subordinate objects, for example. like a Groovy Script system:
hudson = hudson.model.Hudson.instance hudson.slaves.findAll { it.nodeName.equals("slave4") }.each { slave -> print "Slave $slave.nodeName : Labels: $slave.labelString" slave.labelString = slave.labelString + " " + "offline" println " --> New labels: $slave.labelString" } hudson.save()
source share