pom-only 神器意外部署为 jar 到 Artifactory

pom-only artifact unexpectedly deployed as jar to Artifactory

我有一个多模块项目,它有一个根 pom.xml,用 <packaging>pom</packaging> 定义,还有几个 <modules>.

在 Jenkins 上,我 运行 maven 的目标是 jar:jar install:install -Dmaven.test.skip=true(编译和测试已经由构建管道中的先前作业完成)。

作为 post 构建操作,我将工件部署到 Artifactory。我检查了 'Deploy Maven artifacts' 并将 include/exclude 留空,因此它将采用默认值。

子模块正确地将它们的 pom 和 jar 部署到 Artifactory。我在控制台输出中看到了这个:

Deploying artifacts of module: com.example:foo
Deploying artifact: https://repo.example.com/snapshot/com/example/foo/7.0.0-SNAPSHOT/foo-7.0.0-SNAPSHOT.jar
Deploying artifact: https://repo.example.com/snapshot/com/example/foo/7.0.0-SNAPSHOT/foo-7.0.0-SNAPSHOT.pom

root pom 未正确上传到 Artifactory。

当 "Supress POM Consistency Checks" 被 关闭时 ,构建失败并在 root pom 上发生冲突:

Deploying artifacts of module: com.example:root
Deploying artifact: https://repo.example.com/snapshot/com/example/root/7.0.0-SNAPSHOT/root-7.0.0-SNAPSHOT.pom
ERROR: Failed to deploy file: HTTP response code: 409. HTTP response message: Conflict
java.io.IOException: Failed to deploy file: HTTP response code: 409. HTTP response message: Conflict
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.throwHttpIOException(ArtifactoryBuildInfoClient.java:743)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:623)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:329)
    at org.jfrog.hudson.maven2.ArtifactsDeployer.deployArtifact(ArtifactsDeployer.java:190)
    at org.jfrog.hudson.maven2.ArtifactsDeployer.deploy(ArtifactsDeployer.java:130)
    at org.jfrog.hudson.ArtifactoryRedeployPublisher.perform(ArtifactoryRedeployPublisher.java:420)
    at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1047)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
    at hudson.model.Run.execute(Run.java:1763)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Deploy artifacts to Artifactory' changed build result to FAILURE

当 "Supress POM Consistency Checks" 处于 on 时,我在 Artifactory 上检查 root 并转到 "POM View",然后我看到二进制乱码以"PK",表示 ZIP 文件或在本例中可能是 JAR 文件。下载该文件并解压缩为 zip 确认它包含一个 META-INF 目录和一些与 Maven 相关的子目录。

我所期待的是 root 的纯文本 pom.xml

我在控制台日志中也注意到了这一点:

[JENKINS] Archiving /var/lib/jenkins/jobs/example-develop-maven-artifactory/workspace/target/example-root-7.0.0-SNAPSHOT.jar to com.example/root/7.0.0-SNAPSHOT/root-7.0.0-SNAPSHOT.pom

然后

Deploying artifacts of module: com.example:root
Deploying artifact: https://repo.example.com/snapshot/com/example/root/7.0.0-SNAPSHOT/root-7.0.0-SNAPSHOT.pom
Deploying artifact: https://repo.example.com/snapshot/com/example/root/7.0.0-SNAPSHOT/root-7.0.0-SNAPSHOT.pom

据我了解,Artifactory 会拦截构建工具在本地存储库 (~/.m2) 中部署的内容。

如何在 Artifactory 上获取我的 root 的 pom,并且只有 pom,而不是神奇生成的 jar?这可能归结为,我如何告诉 Maven and/or Jenkins 不要用 root jar 覆盖我的 root pom?

版本:

从@khmarbaise 的评论开始,我现在 运行 构建

mvn install \
    -Dmaven.main.skip=true \
    -Dcheckstyle.skip=true \
    -Dfindbugs.skip=true \
    -Dmaven.test.skip=true \
    -Dmaven.site.skip=true \
    -Dmaven.javadoc.skip=true

构建仍然需要 54 秒,这很不幸,但是没有 Yet Another Redundant Compilation,这正是我想要的。

仅 pom root 已正确部署到 Artifactory。