List of Slaves connected to master - Hudson
Asked Answered
A

3

9

Is there a way to find it programatically? I need this as part of an automated run; So this would be very helpful if there is an existing remote API call which can give this.

Abeyta answered 8/7, 2010 at 9:33 Comment(0)
S
23

You don't need to parse the HTML - most of the Hudson pages can be turned into API calls by adding URL suffix, e.g. make GET calls to:

http://hudson:8080/computer/api/json

Switch the JSON for either XML or Python if you prefer these over JSON.

If you use just the API suffix, you'll get a short generic help page on the API.

Sardonic answered 21/7, 2010 at 20:40 Comment(2)
Good, +1! I thought there was something like this, but never got around searching for it.Kresic
1 Was looking for something like that. But under terms like "jenkins environmental variables" but with no luck.Cyanogen
C
8

Groovy script to get all computers:

def jenkins = Jenkins.instance
def computers = jenkins.computers

computers.each{ 
  println "${it.displayName} ${it.hostName}"
}
Cohin answered 30/3, 2017 at 7:58 Comment(2)
looks nice! but where to get info what is "Jenkins" and why there is "instance"? Isn't it possible to write just: Jenkins.instance.computers.each{println "${it.displayName} ${it.hostName}"} ?Preempt
yes, you can write that. it's a matter of taste / coding style.Cohin
K
4

Look at http://hudson:8080/computer/

Kresic answered 8/7, 2010 at 9:39 Comment(3)
Thanks. I saw that. I can parse it and get it as part of my automated run. But wanted to know if there is more specific API for this.Abeyta
@Aviator: Look at openjey's answer. I kept this open in a browser windows because I seemed to remember that there is an API, but never got around digging for that info. Now openjey has answered that.Kresic
Where is the link in the UI to this? How was I suppose to know thisGoiter

© 2022 - 2024 — McMap. All rights reserved.