问题
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