5

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.

Rahul Mohan
  • 493
  • 3
  • 5
  • 18
  • checkout this https://stackoverflow.com/questions/9704677/jenkins-passing-variables-between-jobs, looks like similar to your query check for 2nd and 4th solution, might help – anshul Gupta Jul 26 '17 at 10:58
  • my use case is to create a variable inside one and then pass it to another. I am not able to create the custom variable in the batch command section that i can pass in the parameterized way to another. – Rahul Mohan Jul 26 '17 at 11:13

2 Answers2

3

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.

Suresh
  • 730
  • 1
  • 5
  • 12
3

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

Rahul Mohan
  • 493
  • 3
  • 5
  • 18