Created
October 9, 2018 04:33
-
-
Save hakanai/8f8d110e20de6bd090ceb7cc0db89776 to your computer and use it in GitHub Desktop.
Example of running a command on all slaves
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.util.RemotingDiagnostics | |
Jenkins.instance.slaves | |
.findAll { node -> node.labelString.contains('debian') } // not production-safe | |
.each { slave -> | |
println slave.name | |
def channel = slave.channel | |
if (channel != null) { | |
println RemotingDiagnostics.executeGroovy(""" | |
def p = 'docker --version'.execute() | |
p.waitFor() | |
println p.in.text.trim() | |
""", channel) | |
} else { | |
println 'host is down' | |
println '' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. Very helpful.