How to pass parameter from jenkins to selenium

馋奶兔 提交于 2021-01-01 06:46:05

问题


I'm using jenkins and selenium.

I need to send the testing url to selenium server from jenkins.

Under General Tab

Jenkins String parameter: Name = APP, Default Value = http://localhost/basecode/

Under Post-build Actions

Trigger parameterized build on other projects -> Predefined parameters -> Parameters -> SEL_APP=$APP

Above mentioned SEL_APP value needs to be written in the selenium bat file.

Suggestions are most welcome :-)


回答1:


If you are using maven then you can pass the parameters through maven command.

mvn clean test -Duser=value1 -Dpass=value2

If you are building the Jenkins job with parameters then you can use jenkins parameters in maven command as

clean test -Duser=$jenkinsparam1 -Dpass=$jenkinsparam1

jenkinsparam1 - Jenkins parameter while building a job.

In the code you can use them as

String s1 = System.getProperty("user");
String s2 = System.getProperty("pass");



回答2:


Use File Operations Plugin to create a bat file.

Add File Operations build step and with in it add File Create Operation. It creates the bat file with the contents provided in text area.




回答3:


use %paramerter_name% in your bat file it would directly pick it from jenkins.



来源:https://stackoverflow.com/questions/45565401/how-to-pass-parameter-from-jenkins-to-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!