gpt4 book ai didi

java - 将构建和提交哈希添加到 list

转载 作者:太空狗 更新时间:2023-10-29 14:17:50 26 4
gpt4 key购买 nike

我正在尝试将 jenkins 内部版本号、git 提交哈希等添加到 MANIFEST.MF 文件中。我正在学习本教程:http://akeffalas.github.io/blog/2014/04/jenkins-build-info-maven-artifacts.html

这是我的 POM 的构建部分:

    <build>
<finalName>common</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
<manifestSections>
<manifestSection>
<name>${build.manifest.section}</name>
<manifestEntries>
<Implementation-Title>com.mycompany.stuff</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Build-Number>${build.number}</Implementation-Build-Number>
<Implementation-SCM-Revision>${build.revision}</Implementation-SCM-Revision>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
</configuration>
</plugin>
</plugins>
</build>

但是当我构建它时,我得到的只是:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jenkins
Build-Jdk: 1.8.0_74

我的构建参数是:

clean install -Dbuild.number=${BUILD_NUMBER} -Dbuild.revision=${GIT_COMMIT}

但在日志中,我没有看到程序集插件被调用,我看到了清理、编译、资源、jar 和安装。但没有组装。

要让这个插件运行,我需要做什么特别的事情吗?还是我做的完全错了,我需要完全不同的东西?

最佳答案

对于 Git,您可以自动完成此操作。
要得到这个:

Manifest-Version: 1.0
Built-By: ondra
Build-Time: 2018-10-24T15:04:25Z
Created-By: Apache Maven 3.5.0
Build-Jdk: 1.8.0_181
Main-Class: ch.zizka.myapp.MyMainClass

Name: Versions
Implementation-SCM-Revision: 85e0e665
Implementation-Version: 18.22.1-SNAPSHOT
Implementation-SCM-Branch: feature/gitCommitToManifest

pom.xml 中使用:

        <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals><goal>create</goal></goals>
</execution>
</executions>
<configuration>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
<shortRevisionLength>8</shortRevisionLength>
<attach>true</attach>
<addOutputDirectoryToResources>true</addOutputDirectoryToResources>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
<manifestSections>
<manifestSection>
<name>Versions</name>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-SCM-Revision>${buildNumber}</Implementation-SCM-Revision>
<Implementation-SCM-Branch>${scmBranch}</Implementation-SCM-Branch>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
</configuration>
</plugin>

关于java - 将构建和提交哈希添加到 list ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36666078/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com