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

Proj1=property1

Proj2=property2

Proj3=property3

If the user chooses proj1, property1 should be allocated to it automatically.
Aug 14, 2018 in Jenkins by Hannah
• 18,520 points
8,551 views

1 answer to this question.

0 votes

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

proj1
proj2
proj3

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>
fi
.....
answered Aug 14, 2018 by Kalgi
• 52,350 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
• 7,340 points
3,151 views
+2 votes
4 answers
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, 2019 in Jenkins by Sirajul
• 59,230 points
58,048 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,038 views
+2 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
58,446 views
+3 votes
12 answers

Set environment variables in Jenkins

You can try something like this stages { ...READ MORE

answered Dec 10, 2018 in Jenkins by Celia
108,900 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP