执行Jenkinsfile时如何获取管道配置字段“脚本路径"? [英] How to get the pipeline configuration field 'Script Path' when executing the Jenkinsfile?

查看:570
本文介绍了执行Jenkinsfile时如何获取管道配置字段“脚本路径"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Jenkinsfile(groovy)中获取Jenkins中管道配置字段脚本路径"的内容?

How can I get the content of the pipeline configuration field 'Script Path' in Jenkins from the Jenkinsfile (groovy)?

在此示例中:我想在执行Jenkinsfile本身时获取字符串"Apps/mq-logger/Jenkinsfile".

In this example: I want to get the string 'Apps/mq-logger/Jenkinsfile' when executing the Jenkinsfile itself.

推荐答案

您可以通过这种方式获取脚本路径

You can get a script path this way

def scriptPath = currentBuild.rawBuild.parent.definition.scriptPath

请注意,您必须批准所有这些方法.

Note that you have to approve all these methods.

这篇关于执行Jenkinsfile时如何获取管道配置字段“脚本路径"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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