I have a project where I need to set an environment variable based on a choice parameter the user chooses. Each project has a theme project dependency. I'd like to have the user choose the project and then load the theme name from a property file. Something like
proj1=theme1
proj2=theme2
proj3=theme3
If the user chooses proj1
from the PROJECT_NAME
choice parameter, I want to automatically set THEME_NAME
to be theme1
. What would be the best way to go about this?
I don't want to modify the Jenkins job config whenever a new project is added. Instead, I want to have the mapping in a file so I can have it in version control.
I will provide an alternative solution which I used. I hope it can also be useful for others.
I used Environment Injector Plugin. Go to the plugin manager and install it.
Check Inject environment variables to the build process
property of the Build Environment. Define the following in Groovy Script:
Aha, I found a simple solution! Using the EnvInject plugin, in the job config:
Build Environment
[X] Inject environment variables to the build process
Properties File Path
C:\pathtofile\mapping.properties
Properties Content
THEME_NAME=${${PROJECT_NAME}}
Works like a charm!
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