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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Jenkins Users
I second this question!
Khai Do
unread,
Aug 7, 2015, 11:30:37 AM8/7/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.