简体   繁体   English

Jenkins / Hudson CLI API使用Groovy获取脚本正在运行的节点

[英]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.

相关问题 Jenkins / Hudson CLI API使用Groovy修改节点标签 - Jenkins/Hudson CLI API to modify the node labels using Groovy 使用构建后的Groovy脚本获取构建持续时间(Jenkins / Hudson) - Get build duration using post-build Groovy script (Jenkins/Hudson) 使用 Groovy 脚本在 Jenkins 从节点中运行作业 - Running jobs in Jenkins slave node using Groovy script 如何在 groovy 中使用 Jenkins API 获取 Jenkins 节点的 ip - How to get ip of a Jenkins' node using Jenkins API in groovy jenkins cli,使用groovy脚本签出Subversion - jenkins cli with checkout Subversion using groovy script Jenkins / Hudson Groovy脚本控制台:灵活性 - Jenkins/Hudson Groovy Script Console: Flexibility 外部groovy脚本给出错误:groovy.lang.MissingPropertyException:无此类属性:hudson。 在詹金斯中使用时 - external groovy script is giving error : groovy.lang.MissingPropertyException: No such property: hudson. while using in Jenkins 在Jenkins上运行groovy脚本 - Running groovy script on Jenkins 使用 Hudson/Jenkins API 确定给定的作业当前是否正在运行 - Determine if given job is currently running using Hudson/Jenkins API 如何使用 Groovy 控制台脚本/Jenkins API 从每个 Jenkins 作业获取脚本路径 - How to get Script Path from each Jenkins Jobs using Groovy Console Script/Jenkins API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM