Created
August 2, 2022 04:58
-
-
Save kumbasar/a3e255b6038c2fda2a3f7aebe6727fbd to your computer and use it in GitHub Desktop.
Cancel Jenkins Queues and delete offline nodes
This file contains hidden or 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
import hudson.model.* | |
import jenkins.model.Jenkins | |
def q = Jenkins.instance.queue | |
q.items.findAll { it.task.name }.each { q.cancel(it.task) } | |
for (aSlave in hudson.model.Hudson.instance.slaves) { | |
if (aSlave.getComputer().isOffline() /* || aSlave.getComputer().isOnline() */) { | |
aSlave.getComputer().setTemporarilyOffline(true,null); | |
aSlave.getComputer().doDoDelete(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment