Skip to content

Instantly share code, notes, and snippets.

@gokart23
Created December 11, 2017 07:54
Show Gist options
  • Save gokart23/91a0e7b5c9676d847992106b58b3fc76 to your computer and use it in GitHub Desktop.
Save gokart23/91a0e7b5c9676d847992106b58b3fc76 to your computer and use it in GitHub Desktop.
Delete slaves with a certain label directly from Jenkins master script console
import hudson.slaves.*
import hudson.model.*
for (aSlave in hudson.model.Hudson.instance.slaves) {
if (aSlave.name.indexOf("medium-rt-framework") == 0 && !aSlave.getComputer().isOnline()) {
aSlave.getComputer().setTemporarilyOffline(true, null)
aSlave.getComputer().doDoDelete()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment