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
• 14,070 points
1,120 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
• 40,440 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,890 points
145 views
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
• 25,220 points
877 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
147 views
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
6,171 views
+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
22,135 views