Skip to content

Instantly share code, notes, and snippets.

@phucnh
Forked from malonem/find-dead-executors.groovy
Created December 2, 2016 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phucnh/9f0fc7da827a0d799e079556ed944062 to your computer and use it in GitHub Desktop.
Save phucnh/9f0fc7da827a0d799e079556ed944062 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