Set a Jenkins environment variable based on a job parameter

0 votes
I am trying to set an environment variable based on a choice parameter the user chooses. Each project has a property project dependency. I'd like to have the user choose the project and then load the property name from a property file. Something like




If the user chooses proj1, property1 should be allocated to it automatically.
Aug 14, 2018 in Jenkins by Hannah
• 14,080 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

So if you give choice parameter the name PROJECT_NAME and the choices to be :-


then, Jenkins will automatically assign one of these value(i.e proj1, proj2, proj3) to variable PROJECT_NAME as per the choice triggered to start the build. You can infact use $PROJECT_NAME as a variable anywhere in the job configuration page.

you can use a build shell to perform your mapping the proj1, proj2 and proj3 to property1, property2 and property3.

if [ $PROJECT_NAME = "proj1" ] 
    then <your logic goes here for implementing theme1>
answered Aug 14, 2018 by Kalgi
• 36,870 points

Related Questions In Jenkins

0 votes
1 answer

running a Jenkins job on multiple virtual servers.

Your goals can be achieved by using ...READ MORE

answered May 25, 2018 in Jenkins by shubham
• 6,640 points
0 votes
1 answer

How do I set up a windows_slave agent via JNLP, If I have a Jenkins master configured on linux?

JNLP(JAVA NETWORK LAUNCH PROTOCOL) is used to Connect to/launch ...READ MORE

answered Jun 3 in Jenkins by Sirajul
• 980 points
+13 votes
2 answers
0 votes
1 answer
+2 votes
3 answers

Permission denied error while running a simple job in Jenkins

Hey @Hannah, try changing the permissions using ...READ MORE

answered Oct 25, 2018 in Jenkins by krishti
+1 vote
10 answers

Set environment variables in Jenkins

You can use groovy job file: description('') steps { ...READ MORE

answered Dec 10, 2018 in Jenkins by Galelio

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.