Skip to content

Instantly share code, notes, and snippets.

@zeridon
Created June 4, 2015 15:23
Show Gist options
  • Save zeridon/2fa25e5b51b50b609cdf to your computer and use it in GitHub Desktop.
Save zeridon/2fa25e5b51b50b609cdf to your computer and use it in GitHub Desktop.
Set nodes in jenkins to accept jobs
def requiredNodes = ['node1', 'node2', 'node3'];
def status = 0;
for (node in requiredNodes)
{
println "Searching for $node";
slave = Hudson.instance.slaves.find({it.name == node});
if (slave != null)
{
computer = slave.getComputer();
if (computer.isOffline())
{
println "Error! $node is offline.";
status = 1;
}
else
{
println "OK: $node is online";
if(!computer.isAcceptingTasks())
{
computer.setAcceptingTasks(true);
}
}
}
else
{
println "Slave $node not found!";
status = 1;
}
}
status;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment