2
votes

I am in an environment where Jenkins nodes and jobs are all defined via Groovy files. To define nodes we are using the hudson.slaves.DumpSlave class. I now need to change the value of "Usage" parameter that appears in the slave configuration screen in the Jenkins GUI. By default this parameter is "Utilize this node as much as possible" I can change the value to "Only build jobs with label restrictions matching this node" via the GUI, but I want to set that parameter via Groovy. How can I do this?

I don't see anything related to "Usage" in the DumbSlave API (http://javadoc.jenkins-ci.org/hudson/slaves/DumbSlave.html) - except perhaps the setNodeParameters() method - but in that case, what parameter do I need to set?

1
AFAIR this is set by slave.setMode(hudson.model.Node.Mode.EXCLUSIVE)izzekil

1 Answers

3
votes

slave.setMode(hudson.model.Node.Mode.EXCLUSIVE)

Node.Mode.EXCLUSIVE maps to "Only build jobs with label restrictions matching this node." Node.Mode.NORMAL maps to "Utilize this node as much as possible"

thank you, @izzekil!