Created
February 7, 2017 12:35
-
-
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)
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 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