Jenkins CI构建的Manifest.MF中的SCM信息为空白

时间:2019-06-06 09:44:18

标签: java maven jenkins maven-assembly-plugin

我有一个jenkins构建,它创建了一个多模块项目的可部署jar。一切正常,但是创建的jar中的Manifest文件具有以下属性:

SCM-Revision: 
SCM-Branch: UNKNOWN_BRANCH

当我在本地运行相同的项目构建时,这很好用-我按预期填充了这些字段:

SCM-Revision: 28946
SCM-Branch: trunk

我的maven-assembly-plugin就是这样:

<plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
           <execution>
              <id>package-jar-with-dependencies</id>
              <phase>package</phase>
              <goals>
                 <goal>single</goal>
              </goals>
              <configuration>
                 <finalName>${project.name}_${jenkins.build.number}</finalName>
                 <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                 </descriptorRefs>
                 <archive>
                    <manifestEntries>
                       <Specification-Title>${project.name}</Specification-Title>
                       <Specification-Version>${project.version}</Specification-Version>
                       <Implementation-Version>${jenkins.build.number}</Implementation-Version>
                       <SCM-Revision>${buildNumber}</SCM-Revision>
                       <SCM-Branch>${scmBranch}</SCM-Branch>
                    </manifestEntries>
                 </archive>
                 <appendAssemblyId>false</appendAssemblyId>
                 <outputDirectory>target</outputDirectory>
              </configuration>
           </execution>
        </executions>
</plugin>

Jenkins版本为2.177

Maven版本为3.6.1

Maven程序集版本为3.1.1

Project Java版本为1.8

SVN版本为1.7.14(<-我的本地版本之间的差异为1.9.9)

1 个答案:

答案 0 :(得分:0)

在构建中添加了this plugin,以使用注入的svnkit版本而不是系统的svn实现

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.3</version>
        <executions>
           <execution>
              <phase>validate</phase>
              <goals>
                 <goal>create</goal>
              </goals>
           </execution>
        </executions>
        <configuration>
           <doCheck>false</doCheck>
           <doUpdate>false</doUpdate>
           <revisionOnScmFailure>unavailable</revisionOnScmFailure>
           <providerImplementations>
              <svn>javasvn</svn>
           </providerImplementations>
        </configuration>
        <dependencies>
           <dependency>
              <groupId>org.tmatesoft.svnkit</groupId>
              <artifactId>svnkit</artifactId>
              <version>1.8.9</version>
           </dependency>
        </dependencies>
</plugin>