如何解决Maven - pom 文件 - 创建不同命名的工件
我有一个 pom.xml 文件,作为我的 ci/cd 管道的一部分,它负责使用它执行的 bash 脚本编译项目源代码并运行其测试。
pom 文件最终使用 'attachartifact' 创建了一个工件
这个 pom 文件由 Jenkins 启动,使用 Jenkinsfile 脚本。
目前 jenkins 在 linux docker 代理上运行 pom 文件,该代理已配置编译器将代码编译到某个 linux 发行版(pom 文件责任)。
我想为 Jenkins 添加另一个阶段,为不同的 linux 发行版编译代码;我已经设置了几乎所有的东西,jenkins 阶段已经写好了,我有另一个具有正确编译器的 linux docker 代理,我已经将 Jenkins 配置为用于这个额外的阶段,当我从 jenkins 阶段运行 pom 文件时,编译在正确的代理上成功运行。
我的问题是我希望正在创建的工件具有不同的名称,但我不知道该怎么做。
当前代码:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>XXX.XXX.XXXX</groupId>
<artifactId>XXXX-XXXXXX-XXXXXX</artifactId>
<version>1-SNAPSHOT</version>
</parent>
<groupId>XXXX.XXX.XXXX.XXXXX</groupId>
<artifactId>XXX-XXXXXX</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<scm>
<developerConnection>scm:git:XXXXXXXX</developerConnection>
</scm>
<properties>
<revision>1.0.0-1-SNAPSHOT</revision>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="sh" failonerror="true">
<arg line="build.sh"/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>prepare-tests-run</id>
<phase>prepare-run</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${env.ESX_COMPILATION}</skip>
<target>
<exec executable="sh" failonerror="true">
<arg line="tests.sh"/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>attach-to-artifact</id>
<phase>attach-artifact</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
所以我从中得到的是一个具有命名约定的工件,该命名约定基于父级、groupId、artifactId 和版本配置在顶部。 因此,如果我两次运行 pom 文件,每次使用不同的 docker 代理,我仍然会得到同名的工件,我不想要那样。
我所拥有的只是传递变量的能力,就像我在测试步骤中所做的那样,因为在额外编译之后我不需要测试,只需要编译的工件。
任何帮助将不胜感激。 谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。