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.
Asked
Active
Viewed 1.8k times
3 Answers
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.

robyaw
- 2,274
- 2
- 22
- 29

jey burrows
- 248
- 1
- 4
-
Good, `+1`! I thought there was something like this, but never got around searching for it. – sbi Jul 22 '10 at 07:59
-
1 Was looking for something like that. But under terms like "jenkins environmental variables" but with no luck. – Cutton Eye Jun 19 '18 at 12:44
8
Groovy script to get all computers:
def jenkins = Jenkins.instance
def computers = jenkins.computers
computers.each{
println "${it.displayName} ${it.hostName}"
}

Tidhar Klein Orbach
- 2,896
- 2
- 30
- 47
-
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}"}` ? – Psychozoic Jul 09 '19 at 07:46
-
1yes, you can write that. it's a matter of taste / coding style. – Tidhar Klein Orbach Jul 09 '19 at 09:02
4
Look at http://hudson:8080/computer/

sbi
- 219,715
- 46
- 258
- 445
-
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. – vpram86 Jul 08 '10 at 10:54
-
@Aviator: Look at [openjey's answer](http://stackoverflow.com/questions/3202270/list-of-slaves-connected-to-master-hudson/3303637#3303637). 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. – sbi Jul 22 '10 at 07:58
-
Where is the link in the UI to this? How was I suppose to know this – Alexander Kleinhans Feb 22 '19 at 04:46