# Passing information from one job to another

**URL:** <https://community.jenkins.io/t/passing-information-from-one-job-to-another/11611>\
**Category:** Ask a question\
**Created:** [January 5, 2024, 10:46am UTC](https://community.jenkins.io/t/passing-information-from-one-job-to-another/11611 "2024-01-05T10:46:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leoninidas](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@Leoninidas](https://community.jenkins.io/u/Leoninidas)\
**Post date:** [January 5, 2024, 10:46am UTC](https://community.jenkins.io/t/passing-information-from-one-job-to-another/11611/1 "2024-01-05T10:46:53Z")

</div>

Hello

I have a freestyle project that runs a batch file which does the build job. During execution of that batch file, some information are evaluated and assigned to the environment variables VERSION and VERSION\_ID.  
After the batch file is terminated I trigger a second parametrized freestyle project and I pass the values of these environment variable as parameters.

Here is what I did:

1. I create the required environment variables using Environment Injector plugin.  
2.Then I run my batch file. (Note that the expected values of the variables are printed to the console output!)
2. I run the second job with the variables passed as parameters

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/5/56975070583e8c517f75e7d4f1fa76cee279570e.png)

But the values passed to the second job are the initial values from the first screenshot and not the updated value after the batch file execution.  
Same happens when i echo out the values in a second batch file step.

What am I doing wrong?

I also tried it with a pipeline, where information evaluated by TEST\_JOB\_A should be passed to TEST\_JOB\_B. But I have no idea how to achieve this.

```auto
pipeline {
	agent none
	stages {
		stage('Build') {
			steps {
				build job: 'TEST_JOB_A', parameters: [string(name: 'PARAMETER_A', value: "testA")]
			}
		}
		stage('Create Installer') {
			steps {
				build job: 'TEST_JOB_B', parameters: [string(name: 'VERSION', value: env.VERSION), string(name: 'VERSION_ID', value: env.VERSION_ID), string(name: 'BUILD_NR', value: env.BUILD_NUMBER)]
			}
		}
	}
}

```

Has someone an idea?  
Thanks in advance!

Mario

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [January 5, 2024, 11:40am UTC](https://community.jenkins.io/t/passing-information-from-one-job-to-another/11611/2 "2024-01-05T11:40:15Z")

</div>

Environment variables are process specific and passed to child processes usually but parent process never see changes to them done by child processes. So when you call your bat step a new `cmd` process is started with your environment variables initial value. The variables are now modified and inside the `cmd` process the changes are visible. But as soon as the `cmd` process ends the changes are lost.  
You will need to write the changed values to a file (as a java properties file) that you read in jenkins and then pass it on. In free style jobs you can pass parameters from properties file.

---

<div class="post-metadata">

**Author:** ![Leoninidas](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@Leoninidas](https://community.jenkins.io/u/Leoninidas)\
**Post date:** [January 15, 2024, 5:39am UTC](https://community.jenkins.io/t/passing-information-from-one-job-to-another/11611/3 "2024-01-15T05:39:41Z")

</div>

Writing the values to a file solved the problem! Thanks!
