[英]Environment in Jenkins Pipeline has no variables
Because I couldn't use an environment variable that I thought should exist, I printed all the environment variables in my Jenkins Pipeline script: 因为无法使用我认为应该存在的环境变量,所以我在Jenkins Pipeline脚本中打印了所有环境变量:
node {
for(e in env) {
print "key = ${e.key}, value = ${e.value}"
}
}
This prints: 打印:
key = null, value = null
I'm very surprised by this. 我对此感到非常惊讶。
Why are there no environment variables? 为什么没有环境变量?
Seems to be a bug/limitation. 似乎是错误/限制。 If you look at the implementation , there is no support for iteration.
如果您看一下实现 ,则不支持迭代。
The following works as a workaround: 以下是一种解决方法:
node {
for(e in env.getEnvironment()) {
print "key = ${e.key}, value = ${e.value}"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.