在Jenkinsfile中检索env的所有属性 [英] Retrieve all properties of env in Jenkinsfile

查看:440
本文介绍了在Jenkinsfile中检索env的所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Jenkinsfile内的 env 对象中打印所有可用的属性(及其值)。



当我做的时候

  print env 

我得到:

  org.jenkinsci.plugins.workflow.cps.EnvActionImpl@112cebc2 

所以看起来像 toString 没有在那里实现,如果我不知道它们的名字,我该如何访问这个对象中的属性?

确保你不是在沙盒模式下运行管道脚本,你应该可以使用:

  env.getEnvironment()
code>

请注意,如果您在管道中以沙箱模式运行,则应在脚本批准页面批准该方法: http:// jenkins-host / scriptApproval /


I would like to print all available properties (and their values) in env object inside Jenkinsfile.

When I do

print env

I get:

org.jenkinsci.plugins.workflow.cps.EnvActionImpl@112cebc2

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()

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屋!

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