maven拾取jenkins设置的环境变量 [英] maven picking up environment variable set by jenkins

查看:467
本文介绍了maven拾取jenkins设置的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下maven pom.xml片段从文件jenkins/version.properties中读取名为BUILD_NUMBER的属性.

I am using the following maven pom.xml snippet to read a property called BUILD_NUMBER from a file jenkins/version.properties.

      <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <executions>
                 <execution>
                     <phase>initialize</phase>
                     <goals>
                         <goal>read-project-properties</goal>
                     </goals>
                     <configuration>
                         <files>
                             <file>${project.parent.basedir}/jenkins/version.properties</file>
                         </files>
                     </configuration>
                 </execution>
             </executions>
        </plugin>

Jenkins还具有一个名为$ BUILD_NUMBER的环境变量.我有尝试使用$ BUILD_NUMBER的子pom.xmls,它一直在为$ BUILD_NUMBER选取Jenkins环境变量值,而不是从jenkins/version.properties中获取.我只是想知道maven是否将从文件中读取的值放入环境中?如果是这样,看起来詹金斯似乎已经在写这个值了……

Jenkins also has an environment variable called $BUILD_NUMBER. I have child pom.xmls which try and use the $BUILD_NUMBER, and it keeps picking up the Jenkins environment variable value for $BUILD_NUMBER instead of the one from jenkins/version.properties. I am just wondering if maven puts values it reads from files into the environment? If so, it looks as though Jenkins is over writing this value...

推荐答案

我将BUILD_NUMBER变量更改为其他名称,以便它不会与Jenkins $ BUILD_NUMBER环境变量发生冲突.这似乎已经解决了问题.感谢您的帮助-让我步入正轨.

I changed the BUILD_NUMBER variable to a different name so that it didn't clash with the Jenkins $BUILD_NUMBER environment variable. That seems to have fixed the problem. Thanks for the help - set me on the right track.

这篇关于maven拾取jenkins设置的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆