Created
February 27, 2013 05:30
-
-
Save malonem/5045386 to your computer and use it in GitHub Desktop.
Jenkins script to find dead executors and remove them.
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
// 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() | |
} | |
} | |
} |
Looks like this was using some old APIs, try it this way ...
// get handle to build output
def config = new HashMap()
def bindings = getBinding()
config.putAll(bindings.getVariables())
def out = config['out']
jenkins.model.Jenkins.instance.getComputers().each { computer ->
// check if executor is dead
execList = computer.getExecutors()
for( exec in execList ) {
if (exec.getCauseOfDeath()) {
println("\tNode: ${computer.getDisplayName()}, executer ${exec.getDisplayName()} is dead.")
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
I have single executor on master. So tried instance.master but got exception and I want to start that dead executor. Tried to search method for starting executor but no success.