Skip to content

Instantly share code, notes, and snippets.

@miyakawataku
Last active December 16, 2015 11:09
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 miyakawataku/5425774 to your computer and use it in GitHub Desktop.
Save miyakawataku/5425774 to your computer and use it in GitHub Desktop.
Cleans up Jenkins EC2 slaves which have failed to launch. Use this script as a system groovy script with Groovy Plugin.
import jenkins.model.Jenkins
import hudson.slaves.OfflineCause
for (node in Jenkins.instance.getNodes()) {
computer = node.toComputer()
if (computer.getOfflineCause() instanceof OfflineCause.LaunchFailed) {
node.terminate()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment