[英]Jenkins/Hudson CLI API get the node that the script is running on using Groovy
I am using the Hudson API in Jenkins written in groovy and i want to get the labels of the current slave that the script is running on. 我正在使用以groovy编写的Jenkins中的Hudson API,我想获取脚本正在其上运行的当前从属服务器的标签。 I know i can get the labels that were passed in but that's not what I want. 我知道我可以得到传递的标签,但这不是我想要的。 I can get all the slaves using 我可以使用所有的奴隶
hudson.model.Hudson.instance.slaves 哈德森模型哈德森实例奴隶
but how do I know which one I am running on? 但是我怎么知道我要跑哪一个呢? once I have the node I can change the label using myslave.getAssignedLabels() but getting that node seems to be an issue. 一旦有了节点,就可以使用myslave.getAssignedLabels()更改标签,但是获取该节点似乎是一个问题。 any suggestions? 有什么建议么?
使用Node类中的getAssignedLabels
:
Computer.currentComputer().getNode().getAssignedLabels()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.