user3920295
user3920295

Reputation: 909

jenkins pipeline - to get the environment variable from a job

I have a jenkins parameterized pipeline that is run with a groovy script. There are 3 jobs in this plugin

    JOB1  ----> JOB2 ----> JOB3

JOB1 takes 2 input parameters and generates a parameter "TEMP". I need to use this "TEMP" as input to JOB2 after making some minor changes to it. My pipeline script will make the changes before passing it to JOB2. I see that the JOB1 generates TEMP correctly and I have put it in a environment variable ("temp") in JOB1. How do i access the environment variable in my pipeline script? I tried

     echo "temp variable: " + env.TEMP
     echo "temp variable: " + ${TEMP}

but jenkins pipeline groovy does not recognize these values.

Upvotes: 1

Views: 2592

Answers (1)

T. Putters
T. Putters

Reputation: 59

If the variable is set by the job and isn't a parameter in the build, as in a parameterized build try:

echo "temp variable: " + TEMP
echo "temp variable: " + "${TEMP}"

Upvotes: 2

Related Questions