Jenkins管道中的环境变量 [英] Environment variable in Jenkins Pipeline
问题描述
是否有任何环境变量可用于获取Jenkins管道标题?
Is there any environment variable available for getting the Jenkins Pipeline Title?
我知道我们可以使用$JOB_NAME
来获得自由职业的职位,
但是有什么方法可以用来获取管道名称?
I know we can use $JOB_NAME
to get title for a freestyle job,
but is there anything that can be used for getting Pipeline name?
推荐答案
您可以使用相同的名称(例如JOB_NAME
或env.JOB_NAME
)从groovy访问相同的环境变量.
You can access the same environment variables from groovy using the same names (e.g. JOB_NAME
or env.JOB_NAME
).
从文档中:
可以从Groovy代码中以env.VARNAME或简单地以VARNAME的形式访问环境变量.您也可以写入此类属性(仅使用env.前缀):
Environment variables are accessible from Groovy code as env.VARNAME or simply as VARNAME. You can write to such properties as well (only using the env. prefix):
env.MYTOOL_VERSION = '1.33'
node {
sh '/usr/local/mytool-$MYTOOL_VERSION/bin/start'
}
在构建过程中或构建完成后,还可以通过REST API获得这些定义,并使用构建步骤从上游Pipeline构建中获得这些定义.
These definitions will also be available via the REST API during the build or after its completion, and from upstream Pipeline builds using the build step.
对于其余文档,请从任何管道作业中单击管道语法"链接
For the rest of the documentation, click the "Pipeline Syntax" link from any Pipeline job
这篇关于Jenkins管道中的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!