【发布时间】:2020-03-07 04:14:16
【问题描述】:
我有一个多模块项目,它有一个根 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
当“抑制 POM 一致性检查”开启时,我在 Artifactory 上检查 root 并转到“POM 视图”,然后我看到以“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(修订版 30140)
- 詹金斯 1.643
- Artifactory 插件 2.4.7
【问题讨论】:
-
你为什么这样做:
jar:jar install:install -Dmaven.test.skip=true而不是mvn clean install或者如果你想将这些工件部署到 repo manager 只需使用mvn clean deploy? -
我的问题的第二行已经回答了这个问题:管道中的先前构建作业执行了其他目标。更详细地说,仅运行
jar:jar install:install需要 45 秒,而clean install需要 4.5 分钟,跳过测试(和测试 25 分钟)。 -
为什么要分离这些步骤,因为只是在上一个管道步骤中进行部署?或者使用 Jenkins 而不是 Maven 来进行部署..?
-
抱歉,存在语言障碍。我不是以英语为母语的人。我不明白你的评论。请解释一下。
-
尝试 "mvn deploy -N" 这将只部署父 pom 而不是模块
标签: maven jenkins pom.xml artifactory