1、需要maven-surefire-plugin 插件
完整 maven 配置如下:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<fileName>${openAllStatus}</fileName>
</systemPropertyVariables>
<!-- deprecated -->
<systemProperties>
<property>
<name>openAllStatus</name>
<value>${openAllStatus}</value>
</property>
</systemProperties>
<suiteXmlFiles>
<suiteXmlFile>./testng.xml</suiteXmlFile>
</suiteXmlFiles>
<forkMode>always</forkMode>
</configuration>
</plugin>
</plugins>
2、第一种方式:在插件 maven-surefire-plugin的 < plugin>< configuration>(添加的标签)< /configuration> < /plugin> 中添加 < systemPropertyVariables>< /systemPropertyVariables>标签
3、另一种方式,不推荐使用:在插件 maven-surefire-plugin的 < plugin>< configuration>(添加的标签)< /configuration> < /plugin> 中添加 < systemProperties> < /systemProperties> 标签
4、进入项目jenkins目录的workSpeace下 执行调试:
mvn test -U --batch-mode -f pom.xml -Dtest=addParameterTest -DopenAllStatus=false
5、jenkins中设置参数
6、其中4~5步中的结果是一致的,只是4用于调试 5用于界面设置