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用于界面设置

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐