Last active
June 6, 2017 14:12
-
-
Save nehaljwani/8cc14340dc8745960568bfbbfa4fa66f to your computer and use it in GitHub Desktop.
Jenkins: Delete offline slaves
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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