如何从主服务器查找詹金斯节点的IP地址 [英] How to find the ip address of a jenkins node from the master

查看:1053
本文介绍了如何从主服务器查找詹金斯节点的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从主节点脚本控制台或系统groovy脚本(也在主服务器上运行)运行时,如何获取从属节点的ip地址?

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?

推荐答案

我希望这个简单的脚本就足够了:

I was hoping that this simple script would suffice:

import java.net.*

for (slave in Jenkins.instance.slaves) {
  host = slave.computer.hostName
  addr = InetAddress.getAllByName(host)
  println slave.name + ": " + addr.hostAddress
}

但是至少在我的安装中,它没有给我想要的具有多个网络接口的系统的结果.

But at least with my installation, it does not give me the result I want on the systems that have multiple network interfaces.

您可以使用如何在远程节点上执行系统命令"的答案中的在从属服务器上运行命令"技术. 在每个从站上运行类似/sbin/ifconfig的内容.当然可以为您提供详细信息,但是我没有Groovy的精通技巧来编写输出解析器以提取IP.

You could use the "run a command on the slave" technique from the answer to "How to execute system command on remote node" to run something like /sbin/ifconfig on each slave. That would certainly give you the details, but I don't have the Groovy savvy to write up an output parser to extract the IPs.

这篇关于如何从主服务器查找詹金斯节点的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆