如何将参数从詹金斯传递给硒

如何将参数从詹金斯传递给硒

问题描述:

我正在使用詹金斯和硒.

I'm using jenkins and selenium.

我需要将测试网址从jenkins发送到硒服务器.

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

在常规"标签下

Jenkins字符串参数:Name = APP, Default Value = http://localhost/basecode/

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

在构建后操作中

在其他projects -> Predefined parameters -> Parameters -> SEL_APP=$APP

上面提到的SEL_APP值需要写在硒棒文件中.

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

最欢迎提出建议:-)

如果您使用的是maven,则可以通过maven命令传递参数.

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

mvn clean test -Duser=value1 -Dpass=value2

如果要使用参数构建Jenkins作业,则可以在maven命令中使用jenkins参数作为

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参数.

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");