Skip to content

Instantly share code, notes, and snippets.

@jozenstar
Created January 9, 2020 13:06
Show Gist options
  • Save jozenstar/2c29aef6efe6f76a45c5c03e99a76402 to your computer and use it in GitHub Desktop.
Save jozenstar/2c29aef6efe6f76a45c5c03e99a76402 to your computer and use it in GitHub Desktop.
Active Choice Interactive Parameter
import hudson.util.RemotingDiagnostics
import jenkins.model.Jenkins
String agent_name = 'JENKINS_NODE_NAME'
//groovy script you want executed on an agent
groovy_script = ''' println(['bash', '-c', 'commands'].execute().text)
'''.trim()
String result
Jenkins.instance.slaves.find { agent ->
agent.name == agent_name
}.with { agent ->
result = RemotingDiagnostics.executeGroovy(groovy_script, agent.channel)
}
return result.tokenize()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment