pom-only artifact意外地以jar形式部署到Artifactory

时间:2016-04-28 12:30:13

标签: maven jenkins pom.xml artifactory

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

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

作为构建后动作,我将工件部署到Artifactory。我检查了“部署Maven工件”并将包含/排除留空,因此它将采用默认值。

子模块正确地将它们的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。

当“强制关闭POM一致性检查”关闭时,构建失败,并在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$1.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” 时,我检查Artifactory上的root,然后转到“POM View”,然后我看到以“PK”开头的二进制乱码,表示ZIP文件,或者在这种情况下可能是JAR文件。下载该文件并解压缩为zip确认它包含一个META-INF目录,其中包含一些与Maven相关的子目录。

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

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

[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和/或Jenkins不要用root jar覆盖我的root pom?

版本:

  • Artifactory 3.4.2(rev.30140)
  • Jenkins 1.643
  • Artifactory Plugin 2.4.7

1 个答案:

答案 0 :(得分:0)

从@ 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。