Retrieving Slave nodes' hostname &/or ip address using Python Rest Api

2,713 views
Skip to first unread message

preeti k

unread,
Apr 3, 2015, 8:09:23 AM4/3/15
to jenkins...@googlegroups.com
How can the hostname and ip information of all the slave nodes be retrieved using Jenkins Python Rest API?

The only way I have got the host name is by hitting the URL http://<jenkins url>/computer/<slave node>/config.xml.

But how do I get the list of all hostnames in one go in Python?

Eric Wang

unread,
Aug 4, 2015, 9:12:46 PM8/4/15
to Jenkins Users
I second this question! 

Khai Do

unread,
Aug 7, 2015, 11:30:37 AM8/7/15
to Jenkins Users
It's http://host/computer/api/json or you can use one of the libraries like python-jenkins and there's a get_nodes() method that will also retrieve that info.

Khai Do

unread,
Aug 7, 2015, 12:34:11 PM8/7/15
to Jenkins Users
Sorry that doesn't retrieve the IP address.  It doesn't look like there's a rest endpoint to get all slave's IPs in one call.  Looks like you'll need to build that list by making multiple REST requests.  I think that's easy enough if you use the library i referenced.  You can probably just use the get_nodes() method to retrieve all the slave names and then iterate over the slaves and call the get_node_config() method to retrieve the ip address for each node.  Hope that helps.  
Reply all
Reply to author
Forward
0 new messages