I have a Jenkins project with one "Execute shell" that executes some bash commands and exports one variable to the env. variables:
#!/bin/bash
...
TARGET_FULLPATH="blablabla"
export TARGET_FULLPATH
In addition, I have configured to "Post-build Actions" with:
But, when I run this project the other project that will start as soon the first one is finished seems that it doesn't get the parameter FULLPATH at all!
At least in the "Execute shell" (of the second project) the bash script print nothing for echo $FULLPATH! Also at the "Environment Variables" of the second project the FULLPATH is not included!
Any clue what am I doing wrong?
One more thing, i can't use a properties file to store the parameters, since the two projects are running on different servers and there are restrictions on copying files between those servers!
Did you have a look to this solution? Jenkins: How to use a variable from a pre-build shell in the Maven "Goals and options"
Using a shell pre-build step + the InjectEnv plugin, you should be able to solve your problem.
Update from June 22nd, I add some screen copies.
1/ Add a first "Execute shell" script to create the properties file and an "Inject environment variables" step to load the properties file:
2/ For the demo, I add a "post-build task" step to read the variable
3/ Here is the console output, it works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With