Skip to content

Instantly share code, notes, and snippets.

@nehaljwani
Last active June 6, 2017 14:12
Show Gist options
  • Save nehaljwani/8cc14340dc8745960568bfbbfa4fa66f to your computer and use it in GitHub Desktop.
Save nehaljwani/8cc14340dc8745960568bfbbfa4fa66f to your computer and use it in GitHub Desktop.
Jenkins: Delete offline slaves
import jenkins.model.Jenkins
println "Cleaning up offline slaves..."
Jenkins.instance.slaves.each {
if(it.getComputer().isOffline() && !it.getComputer().isAcceptingTasks()) {
println "Deleting ${it.name}"
it.getComputer().doDoDelete()
}
}
println "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment