简体   繁体   English

如何使.properties从Jenkins读取参数

[英]How to make .properties read parameters from Jenkins

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 我使用Jenkins定期运行回归,我有一个带有'ATC.properties'的java-maven项目,在其中可以通过取消注释相应的注释来选择浏览器,环境等。

#### 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 因此,我必须提交它,进行推送,并且只有在Jenkins上的该工作之后,“ ATC.properties”中的选定参数也将运行构建

How can I make my maven project read parameters from parametrised Jenkins build. 如何使我的Maven项目从参数化的Jenkins构建中读取参数。 Can any one give me some example with browser ? 有人可以用浏览器给我一些例子吗? Do I have to use another one '.properties' file with described variables like 我是否必须使用另一个带有描述的变量的“ .properties”文件

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

in my project ? 在我的项目中?

Parameters defined in Jenkins will be expanded at run in Maven Build , Below process does not require additional property file : Jenkins中定义的参数将在Maven Build中运行时进行扩展,以下过程不需要其他属性文件:

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. 现在,用${browser_name}替换pom.xml,您需要选择读取浏览器值而不是从属性文件读取值。

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM