如何使用Groovy在Jenkins中获取当前正在运行的作业的节点名称 [英] How to get currently running job's node name in jenkins using groovy

查看:101
本文介绍了如何使用Groovy在Jenkins中获取当前正在运行的作业的节点名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在"Windows-prod"节点上运行了sample-job.如何使用groovy脚本获取节点名称?

I have sample-job running on node "Windows-prod" node. How can I get the node name using groovy script?

推荐答案

您的问题含糊.有两种方法可以运行groovy脚本..在控制台上运行groovy(..../script)的Groovy插件

Your question is vague. There are two ways to run groovy scripts.. Groovy plugin on Console which runs groovy (..../script)

以下内容是使用groovy控制台列出作业的节点

The following is for listing node for job using groovy console

def item = hudson.model.Hudson.instance.getItem("createAndPublishSnapshot") 
def build = item.getLastBuild()

println build.isInProgress()
println build.getBuiltOn().getNodeName()

这篇关于如何使用Groovy在Jenkins中获取当前正在运行的作业的节点名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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