在 Jenkinsfile 中检索 env 的所有属性 [英] Retrieve all properties of env in Jenkinsfile
本文介绍了在 Jenkinsfile 中检索 env 的所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Jenkinsfile 内的 env
对象中打印所有可用的属性(及其值).
I would like to print all available properties (and their values) in env
object inside Jenkinsfile.
当我这样做
print env
我明白了:
org.jenkinsci.plugins.workflow.cps.EnvActionImpl@112cebc2
所以看起来 toString
没有在那里实现,如果我不知道它们的名字,我如何访问这个对象中的属性?
So it looks like toString
is not implemented there, how can I access properties that are in this object if I don't know their names?
推荐答案
确保您没有在沙盒模式下运行管道脚本,并且您应该能够使用:
Make sure you're not running the pipeline script in sandboxed mode and you should be able to use:
env.getEnvironment()
注意,如果您在管道中以沙盒模式运行,您应该在脚本批准页面批准该方法:http://jenkins-host/scriptApproval/
Note, if you're running in sandbox mode in a pipeline, you should approve the method at the script approval page: http://jenkins-host/scriptApproval/
这篇关于在 Jenkinsfile 中检索 env 的所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文