How to find the ip address of a jenkins node from the master

后端 未结 2 443
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-15 09:11

Running from the master node scripting console, or from the a system groovy script (that also runs on the master), how do I get the ip address(es) of a slave node?

2条回答
  •  礼貌的吻别
    2021-01-15 09:36

    @Dave Bacher's answer will give you all IP's for the given host. Assuming your slaves are SSH based, this will give you strictly the IP that the agent uses:

    def jenkins = jenkins.model.Jenkins.instance
    for (node in jenkins.nodes) {
      println "${node.nodeName}: node.toComputer().launcher.host"
    }
    

提交回复
热议问题