Skip to content

Instantly share code, notes, and snippets.

@blaffoy
Created February 7, 2017 12:35
Show Gist options
  • Select an option

  • Save blaffoy/0b1a64675605ade72f16dd7221f5a1c2 to your computer and use it in GitHub Desktop.

Select an option

Save blaffoy/0b1a64675605ade72f16dd7221f5a1c2 to your computer and use it in GitHub Desktop.
get hostnames of all agents in a jenkins system (including master, if it has executors)
import jenkins.model.Jenkins
agents = Jenkins.instance.slaves
agent_hosts = agents.collect({slave -> return slave.computer.launcher.getHost() })
master_host = new URI(jenkins.model.JenkinsLocationConfiguration.get().getUrl()).getHost()
println Jenkins.instance.getNumExecutors() == 0 ? agent_hosts : agent_hosts << master_host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment