Skip to content

Instantly share code, notes, and snippets.

@techact
Created November 26, 2021 05:41
Show Gist options
  • Save techact/d137227a87f9e1e2f24be843ca628402 to your computer and use it in GitHub Desktop.
Save techact/d137227a87f9e1e2f24be843ca628402 to your computer and use it in GitHub Desktop.
Jenkins - delete offline slave nodes
Closure query = { it.name ==~ /^.*$/ }
Closure action = {
println('====================')
println("Name: ${it.name}")
println("LabelString: ${it.labelString}")
println("NumExectutors: ${it.numExecutors}")
println("RemoteFS: ${it.remoteFS}")
println("Mode: ${it.mode}")
println("RootPath: ${it.rootPath}")
println("Offline: ${it.computer.offline}")
if (it.computer.offline) {
println("Deleting node: ${it.name}")
it.computer.doDoDelete()
}
}
Jenkins.instance.slaves.findAll(query).each(action)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment