I am trying to reboot nodes that are under a master node in Jenkins using Groovy. However, the reboot isn't working and it's only taking the nodes offline and then bringing them back online. Why isn't the reboot command working? Am I missing something? This is what I currently have:
Jenkins jenkins = Jenkins.getInstance()
def jenkins_Nodes = jenkins.getNodes()
for (Node node in jenkins_Nodes) {
if(node.name == "some computer name") {
node.getComputer().setAcceptingTasks(false);
while(true) {
if(node.getComputer().countBusy() == 0) {
def restart = "shutdown /r /f".execute();
restart.waitFor();
break;
}
}
node.getComputer().launch();
node.getComputer().setAcceptingTasks(true);
}
//other computers
}