【问题标题】:Jenkins and Maven Integration: Environment Variables are NULLJenkins 和 Maven 集成:环境变量为 NULL
【发布时间】: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


【解决方案1】:

【讨论】:

  • 能否请您解释一下我是 Maven 新手,这些天我一直在使用。
  • 整理好了,谢谢罗伯特。
  • @Prashanna:如果它是解决方案,请不要忘记接受这个答案。要接受答案,请单击左侧的刻度线,使其变为绿色。这就是我们感谢贡献者在这里所做的努力的方式。
猜你喜欢
  • 1970-01-01
  • 2018-10-18
  • 1970-01-01
  • 1970-01-01
  • 2014-02-06
  • 2013-12-02
  • 2019-02-08
  • 1970-01-01
  • 2017-08-09
相关资源
最近更新 更多