How to manage offline slaves using groovy?


I have some slaves connected via ssh and some slaves (windows) connected via swarm plugin. Many times these slave go offline and cannot recover. I manually remove them by going to node > slave > delete slave.

How can I do this via groovy? Basically get a list of offline slaves, check the slave log for some text, if text matches some string delete this slave.


  • CloudBees Jenkins Enterprise
  • Swarm plugin
  • Windows


We’re not aware of a script that has already coded this for exactly what you’re looking for. However, in the **Jenkins Script Console **you can find some examples similar to what you want.

For example the Monitor and Restart Offline Slaves script can help you to start.

Then, you need to code the second part in which you want to check the slave log and delete if needed.

Have more questions? Submit a request


Please sign in to leave a comment.