简体   繁体   English

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

[英]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.

相关问题 如何将参数从Selenium Webdriver传递给JMeter? - How to pass parameter from Selenium Webdriver to JMeter? 如何从jenkins将多个参数传递给Cucumber Runner文件 - How to pass multiple parameter to Cucumber Runner file from jenkins Jenkins通过浏览器URL作为Maven Selenium Java测试的参数 - Jenkins pass browser URL as parameter of a Maven Selenium Java test 如何在运行时获取Selenium / java中的jenkins参数 - How to get jenkins parameter in selenium / java on run time 如何从Jenkins运行Selenium Script(Junit) - How to run Selenium Script (Junit) from Jenkins 如何使用junit将数据从二维参数数组传递到selenium rc中的type()函数 - how to pass data from a two dimentional parameter array to type() function in selenium rc using junit 使用 Spectron 或 selenium 测试基于电子的应用程序,从 cmd 启动 Electron 需要传递参数,如何传递参数? - Use Spectron or selenium test electron based application, start Electron from cmd need pass parameter, how to pass parameters? Selenium Java-从pageObjects通用函数传递布尔参数 - Selenium java - Pass boolean parameter from pageObjects Common function 硒将参数从pageObjects传递给@Test - selenium pass parameter to @Test from pageObjects Common function 如何通过量角器传递Selenium Server日志参数 - How To Pass Selenium Server Log Parameter Via Protractor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM