Rahul Mohan
Rahul Mohan

Reputation: 533

How to set a variable inside Jenkins Shell Command

I have a Jenkins build job. It has section for shell command where I read "version" of the current application that i am building. Now, i want to set the Jenkins custom variable "VERSION" with the "version" in the same shell command section. I need to pass this value as parameter to some other job being triggered after successful build of this job.

enter image description here

Now, I would pass the Jenkins variable VERSION to some other Job.

enter image description here

Please suggest how can I do this.

Upvotes: 5

Views: 17459

Answers (2)

Rahul Mohan
Rahul Mohan

Reputation: 533

I could get some clue from Suresh's answer. I did the following steps and it worked well.

Step 1: Install Plugin “EnvInject Plugin”.

enter image description here

Step 2: Set the custom env variable and store that in env.properties

enter image description here

Step 3: Add POST Build Action, “Trigger parameterized build on other projects”

enter image description here

Step 4: Add the variables that the Post Build Job is expecting: Here the BUILD_NUMBER and FILE_VERSION are two parameterized variables that the next Job is expecting. FILE_VERSION is passed as parameters from properties file which was stored in STEP 2.

enter image description here

Upvotes: 3

Suresh
Suresh

Reputation: 750

Use EnvInject Plugin to inject runtime variables into Jenkins build process so that you can use in other build steps or you can pass it on to other Job's as input parameter.

Upvotes: 3

Related Questions