I have a bash script that I execute from a Jenkins job, using "execute shell".
The script starts an EC2 instance and sets an host
variable containing the host name of the new instance.
I would like to set the host name of the new instance (script variable: host
) to a Jenkins environment variable so that I can pass it down to a downstream job (possibly using the Build Flow plugin).
Any idea how to do so?
Thanks
You can set your own variables at the command line per session, or make them permanent by placing them into the ~/. bashrc file, ~/. profile , or whichever startup file you use for your default shell. On the command line, enter your environment variable and its value as you did earlier when changing the PATH variable.
We can set global properties by navigating to “Manage Jenkins -> Configure System -> Global properties option”.
I ended up using a file to propagate data between builds. The first build creates a file containing the information I need to propagate (host name of the newly created EC2 instance). The file looks like:
host.name=ec2.123.3345.amazon.com
I use the EnvInject plugin to read the file and "inject" the properties that are then available in the next build (I'm using the Build Flow Plugin to orchestrate builds).
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