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
• 35,800 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,500 points
0 votes
1 answer

How to start Jenkins on a different port rather than 8080?

This is simple, use the following command: java ...READ MORE

answered Jul 4, 2018 in Jenkins by Sophie may
• 9,050 points
0 votes
1 answer

I’m facing a login error when I try to run Jenkins on Docker. How do I solve this?

You have to open the /var/log/jenkins/jenkins.log file to ...READ MORE

answered Jul 24, 2018 in Jenkins by Sophie may
• 9,050 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.