ziyao

  博客园 :: :: 新随笔 :: :: :: 管理 ::

Quick tip: Passing parameters from Jenkins to Maven

I saw bits and pieces of information all over the internet about parameters and properties and command-line arguments, but what I was looking for I didn’t find: a simple, straightforward explanation of how to use a Paramaterized Build in Jenkins to pass arguments through to the jUnit tests that run the functional tests that I’ve built on Webdriver. So: here it is!
Step 1: Command-line via Maven to jUnit
Use the System.getProperty tor ead system properties in Java:
  remoteHost = System.getProperty("remoteHost");
  if (remoteHost == null) remoteHost = "http://localhost:4444/wd/hub";
  browserName = System.getProperty("browserName");
  if (browserName == null) browserName = "Internet Explorer";
And use -D to pass them with Maven:
  mvn test -DbrowserName=Firefox

Step 2: Jenkins to Maven
First make the build a paramaterized build:

Then adjust the maven build step as shown:

(Quotes are important here because of Internet Explorer)

posted on 2017-03-07 11:16  ziyao  阅读(166)  评论(0)    收藏  举报