Created
May 21, 2020 23:21
-
-
Save gwsu2008/0555ab4efbdecb654dddc6697daaadd6 to your computer and use it in GitHub Desktop.
jenkins-groovy-get-nodes.groovy
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.FilePath | |
import hudson.model.Node | |
import hudson.model.Slave | |
import jenkins.model.Jenkins | |
Jenkins jenkins = Jenkins.instance | |
for (Node node in jenkins.nodes) { | |
// Make sure slave is online | |
if (!node.toComputer().online) { | |
println "Node '$node.nodeName' is currently offline - skipping workspace cleanup" | |
continue | |
} | |
println "Node '$node.nodeName' is online - performing cleanup:" | |
// Do some cleanup | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment