[英]How to pass parameter from jenkins to selenium
I'm using jenkins and selenium. 我正在使用詹金斯和硒。
I need to send the testing url to selenium server from jenkins. 我需要将测试网址从jenkins发送到硒服务器。
Under General Tab 在常规标签下
Jenkins String parameter: Name = APP, Default Value = http://localhost/basecode/
Jenkins字符串参数:
Name = APP, Default Value = http://localhost/basecode/
Under Post-build Actions 在构建后操作下
Trigger parameterized build on other projects -> Predefined parameters -> Parameters -> SEL_APP=$APP
在其他
projects -> Predefined parameters -> Parameters -> SEL_APP=$APP
上触发参数化构建projects -> Predefined parameters -> Parameters -> SEL_APP=$APP
Above mentioned SEL_APP
value needs to be written in the selenium bat file. 上面提到的
SEL_APP
值需要写入硒bat文件中。
Suggestions are most welcome :-) 最好的建议是:-)
If you are using maven then you can pass the parameters through maven command. 如果使用的是maven,则可以通过maven命令传递参数。
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 如果要使用参数构建Jenkins作业,则可以在maven命令中使用jenkins参数,如下所示:
clean test -Duser=$jenkinsparam1 -Dpass=$jenkinsparam1
jenkinsparam1 - Jenkins parameter while building a job. jenkinsparam1-构建作业时的Jenkins参数。
In the code you can use them as 在代码中,您可以将它们用作
String s1 = System.getProperty("user");
String s2 = System.getProperty("pass");
Use File Operations Plugin to create a bat file. 使用文件操作插件来创建bat文件。
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.
它使用文本区域中提供的内容创建bat文件。
在bat文件中使用%paramerter_name%,它将直接从jenkins中选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.