如何列出jenkins管道工作中的所有`env`属性? [英] How to list all `env` properties within jenkins pipeline job?
本文介绍了如何列出jenkins管道工作中的所有`env`属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
节点{}
中注入一个 env
变量。例如, BRANCH_NAME
可以通过 node {
echo $ {env.BRANCH_NAME}
...
我想在jenkins管道中echo all env
属性。
m寻找类似于
的代码 node {
for(e env){
echo e +is+ $ {e}
}
...
这将回显类似于
BRANCH_NAME是myBranch2
CHANGE_ID是44
...
解决方案
简洁的方式:
node {
echo sh(returnStdout:true,script:'env')
// ...
}
Given a jenkins 2.1 build pipeline, jenkins injects a env
variable into the node{}
. For example, BRANCH_NAME
can be accessed with
node {
echo ${env.BRANCH_NAME}
...
I want to echo all env
properties within the jenkins pipeline.
I'm looking for code like
node {
for(e in env){
echo e + " is " + ${e}
}
...
which would echo something like
BRANCH_NAME is myBranch2
CHANGE_ID is 44
...
解决方案
Another, more concise way:
node {
echo sh(returnStdout: true, script: 'env')
// ...
}
cf. https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-sh-code-shell-script
这篇关于如何列出jenkins管道工作中的所有`env`属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文