Reputation: 1211
In the scripts console, i can get information on the nodes with a groovy script like:
for (nodes in Jenkins.instance.getNodes()) {
if (nodes.labelString=="") {
println(nodes.getNodeName()) } }
or
for (nodes in Jenkins.instance.getNodes()) {
println(nodes.getNodeName())
}
Which returns a list of node names for the entire Jenkins instance.
I want to do the same thing with something like:
curl -X get http://<jenkins-endpoint>/nodes/api/json -d json
Does the Jenkins API allow for that or can I only interact with jobs as shown in the link below? https://www.jenkins.io/doc/book/using/remote-access-api/
Upvotes: 1
Views: 2133
Reputation: 972
JenkinsAPI works with almost anything in Jenkins. You can try the following to get a list of all nodes in my case physical computers listed in jenkins instance.
XML
http://jenkinsinstance/computer/api/xml
JSON
http://jenkinsinstance/computer/api/json
This will give you following:
1 - class type of the node
2 - Labels you have assigned
3 - The display name of the node.
This is the list of all nodes in jenkins instance.
Upvotes: 2