小编典典

maven获取jenkins设置的环境变量

jenkins

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

      <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是否会将其从文件读取的值放入环境中?如果是这样,看起来詹金斯似乎已经在写这个值了……


阅读 577

收藏
2020-07-25

共1个答案

小编典典

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

2020-07-25