Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

groovy - Retrieve all properties of env in Jenkinsfile

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...