Getting an IP Address through Jenkins REST API?

泪湿孤枕 提交于 2019-12-05 10:22:11

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!