Skip to content

Instantly share code, notes, and snippets.

@olblak
Created November 12, 2020 10:10
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 olblak/db627bd25e5179e54688e59f67d6fd0c to your computer and use it in GitHub Desktop.
Save olblak/db627bd25e5179e54688e59f67d6fd0c to your computer and use it in GitHub Desktop.
Delete nodes
#!/usr/bin/env groovy
/* Delete online nodes matching a pattern */
Jenkins.instance.computers.each { c ->
/*
* Delete all offline nodes
*/
if (c.isOffline()) {
println "Agent ${c.name} offline, deleting"
c.doDoDelete()
}
//if ((c.executors.size() > 0) && (c.name.matches(/Azure.*/)) && (c.isOnline())) {
// println "Deleting: ${c.name}"
// c.doDoDelete()
//}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment