Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lepffm/a538f4db9186e73a1e46165b6e38abc9 to your computer and use it in GitHub Desktop.
Save lepffm/a538f4db9186e73a1e46165b6e38abc9 to your computer and use it in GitHub Desktop.
How to execute a remote command on the Jenkins Script Console
import hudson.util.RemotingDiagnostics;
def node = 'node-name'
def command = 'uname -a'
println RemotingDiagnostics.executeGroovy("""
def p = '$command'.execute()
p.waitFor()
println p.in.text
""", Jenkins.instance.slaves.find { it.name == node }.channel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment