Maven Surefire插件+ SystemPropertyVariables

时间:2018-07-12 09:55:17

标签: maven

我在Eclipse运行配置中添加了一个新参数,称为cversion->“ xxx”。

现在在testng测试用例中,我尝试使用System.getProperty()来获取值。 这将正确返回值“ xxx”。

P.S:我在pom.xml中添加了maven-surefire插件,但未添加systemproperty变量。

现在,如果我尝试在Jenkins中运行测试,则systemproperty变量不会返回预期值。它为空。

有人可以解释这种现象的原因吗?

1 个答案:

答案 0 :(得分:0)

您可以使用-D作为系统属性传递给Maven Runner。

mvn -DpropertyName=propertyValue

有人问过类似的问题,并在这里回答:https://stackoverflow.com/a/34716689/3266467