Skip to content

Instantly share code, notes, and snippets.

@hakanai
Created October 9, 2018 04:33
Show Gist options
  • Save hakanai/8f8d110e20de6bd090ceb7cc0db89776 to your computer and use it in GitHub Desktop.
Save hakanai/8f8d110e20de6bd090ceb7cc0db89776 to your computer and use it in GitHub Desktop.
Example of running a command on all slaves
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 ''
}
}
@littleccguy
Copy link

Thank you. Very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment