Access to all environment vars as map from job dsl

111 views
Skip to first unread message

John Lonergan

unread,
Jun 1, 2018, 3:07:11 PM6/1/18
to Jenkins Users
Within job dsl...

How can I obtain a map of environment vars containing the usual Jenkins environment vars.

I need as a map rather than broken out as individual cats line $Build_url etc

John Lonergan

unread,
Jun 1, 2018, 3:30:51 PM6/1/18
to Jenkins Users
.... rather than idividual vars like ..

DmitryB

unread,
Jun 1, 2018, 4:44:44 PM6/1/18
to Jenkins Users
println env.getEnvironment()["JENKINS_HOME"]

DmitryB

unread,
Jun 1, 2018, 4:49:28 PM6/1/18
to Jenkins Users
Also it can be used as 
printlnenv.JENKINS_HOME

John Lonergan

unread,
Jun 2, 2018, 8:17:44 AM6/2/18
to Jenkins Users
Doesn't work.

I am talking about accessing the environment from a job DSL groovy script.

My script is called test_dsl.groovy

It gives "no such property: environment for class: test_dsl"

John Lonergan

unread,
Jun 2, 2018, 8:18:43 AM6/2/18
to Jenkins Users
"No such property:env for class"

John Lonergan

unread,
Jun 3, 2018, 5:11:59 PM6/3/18
to Jenkins Users
Any ideas anyone how to get access to the environment map in a job DSL groovy script?
Surprisingly 'env' is not accessible in a job DSL groovy script

Victor Martinez

unread,
Jun 6, 2018, 10:53:17 AM6/6/18
to Jenkins Users
Reply all
Reply to author
Forward
0 new messages