I've been working on Groovy code to do this. Essentially it takes the slave "offline" (equivalent to clicking "Mark this node temporarily offline" button). Any running jobs on the slave continue, but no new jobs are accepted. Once the slave is offline it goes into a loop monitoring the countBusy() method on the slave's computer object. When the value gets down to 1 (the currently running shutdown job) it is safe to go ahead and reboot.

I started with code from https://bugreports.qt-project.org/browse/QTQAINFRA-558, and added the loop to monitor busy executors. Also, you will need to bring the slave back online after it reboots, because it will remember it was taken offline. I used the code from https://wiki.jenkins-ci.org/display/JENKINS/Monitor+and+Restart+Offline+Slaves .

Regards,
Eric


On 3/4/2014 9:18 PM, Andrew Sumner wrote:
I'm searching for a more robust way of rebooting a Windows slave. I reboot our windows slaves every night as I find that they tend to play up if left too long without a restart.

Currently I try to a block builds plugin to block jobs so that the slave can be rebooted, however from time to time a job will fail because it got triggered in the narrow window between the reboot being triggered and the slave shutting down, or if the slave is particularly busy it might be hours before the reboot job can get started.

I've wondered about giving up on the blocking mechanism and create a job that would run on the Slave, using Jenkins CLI to take the node offline, wait for any currently running jobs (except for itself) to complete, and then reboot the slave - I am assuming the node would automatically come back online.

1. Is this a sensible idea?
2. If so - how do I check if any jobs are running on a node?
3. Anyone have a better idea?

Ta
  Andrew

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com <mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to