1

I use Jenkins to run regression periodically I have java-maven project with 'ATC.properties' where I can choose browser, environment etc. by uncommenting appropriate one

#### browser ######
browser.name=firefox
#browser.name=chrome
#browser.name=ie

So I have to commit it, push and only after that job on Jenkins will run build with chosen parameters in 'ATC.properties' as well

How can I make my maven project read parameters from parametrised Jenkins build. Can any one give me some example with browser ? Do I have to use another one '.properties' file with described variables like

browser.name=${browser.name} ... 

in my project ?

stusyura
  • 11
  • 1
  • 5
  • you can choose one of the 3 solutions in the topic : [Stackoverflow][1] you can choose meven profile solution is the best for me [1]: http://stackoverflow.com/a/9478622/3584773 – Inforedaster Sep 03 '15 at 13:02

1 Answers1

1

Parameters defined in Jenkins will be expanded at run in Maven Build , Below process does not require additional property file :

Define jenkins choice parameter :

browser_name

Provide all your Browsers options as choices and select the required option at run time.

Now replace your pom.xml with ${browser_name} where you required the option of reading browser value instead of reading value from property file.

pass parameter at run time as below

mvn clean install -Dbrowser_name=%browser_name% [incase of windows]
mvn clean install -Dbrowser_name=$browser_name  [incase of linux]
prudviraj
  • 3,634
  • 2
  • 16
  • 22
  • Can you please give more information or some piece of example about "Now replace your pom.xml with ${browser_name} where you required the option of reading browser value instead of reading value from property file." - I want to have possibility locally switch environment by comment - uncomment in ATC.properties and also on independently on Jenkins Thanks a lot – stusyura Sep 03 '15 at 15:05
  • i believe you pass browser using ATC,properties files in the property tag of pom.xml , i suggest u to replace that with ${browser_name} , which will expand to the value you selected in jenkins run, and locally when u run you can directly give the value in -Dbrowser_name=chrome , which will do the same thing – prudviraj Sep 04 '15 at 06:00
  • What to do if I don't use any related tag with browser in POM - my code gets this parameter by key from ATC.properties: browser.name=firefox #browser.name=chrome #browser.name=ie In this case active browser is firefox – stusyura Sep 04 '15 at 09:29