【发布时间】:2015-07-30 07:34:04
【问题描述】:
我正在尝试在 Maven 构建过程中注入环境变量,以便我可以在我的测试脚本中将它们用于各种目的。
以下是我的 Maven 依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.46.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<jenkins.package>${env.V_PACKAGE}</jenkins.package>
<jenkins.release>${env.V_RELEASE}</jenkins.release>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
在我的测试脚本中,我试图读取这些构建参数,但我得到的都是空值,你能帮我解决这个问题吗?
在测试脚本中
String VANSAH_PACKAGE=System.getProperty("jenkins.package");
String VANSAH_RELEASE=System.getProperty("jenkins.release");
System.out.println(" V_PACKAGE :" + V_PACKAGE);
System.out.println(" V_RELEASE :" + V_RELEASE);
我的 Jenkins 字符串参数是
V_PACKAGE
V_RELEASE
【问题讨论】:
-
请不要将您的任何 Stack Overflow 问题标记为紧急 - 志愿者将在闲暇时回答。谢谢。
标签: maven variables jenkins continuous-integration environment