Getting an IP Address through Jenkins REST API? Getting an IP Address through Jenkins REST API? jenkins jenkins

Getting an IP Address through Jenkins REST API?


You can execute groovy script on your slave via REST API, thus can get slave's ip address. Here is an example with curl, but you can adjust it to use in your code:

$ curl -u username:password -d "script=println InetAddress.localHost.hostAddress" jenkins_url/computer/node_name/scriptText# 192.168.0.104

Node: to get an ip-address of a particular slave, you have to know it's name. That's easy to grad nodes names querying jenkins_url/computer/api/json

I am going to try scraping the HTML of the node page to grab the IP from the swarm slave description

This will not always work as slave may be connected via JNLP and you will not have an IP on that HTML page.