Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WoodProgrammer/95db52fba3243d8a8301d7dcdac043b3 to your computer and use it in GitHub Desktop.
Save WoodProgrammer/95db52fba3243d8a8301d7dcdac043b3 to your computer and use it in GitHub Desktop.
Jenkins script to find dead executors and remove them.
// get handle to build output
def config = new HashMap()
def bindings = getBinding()
config.putAll(bindings.getVariables())
def out = config['out']
for (aSlave in hudson.model.Hudson.instance.slaves) {
// check if executor is dead
execList = aSlave.getComputer().getExecutors()
for( exec in execList ) {
if (exec.getCauseOfDeath()) {
println("\tSlave ${aSlave.name} has a dead executor.")
println("Error:")
exec.getCauseOfDeath().printStackTrace(out)
println('\n')
println("\tRemoving Dead Executor.")
exec.doYank()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment