我有一個根模塊pom.xml
,使用<packaging>pom</packaging>
和幾個<modules>
定義的多模塊項目。pom-only artifact意外地部署爲Artifactory的罐子
在Jenkins上,我運行了目標jar:jar install:install -Dmaven.test.skip=true
的maven(編譯和測試已經由構建管道中的以前的作業完成)。
作爲構建後的操作,我將工件部署到Artifactory。我選中了「部署Maven工件」,並將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的。
當「剿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一致性檢查」是上,我就查root
Artifactory和我去「POM視圖」,然後我看到二進制的亂碼開始與「PK」,這表明一個ZIP文件或在這種情況下可能是一個JAR文件。下載該文件並解壓縮爲zip並確認它包含META-INF
目錄以及與Maven相關的一些子目錄。
我期待的是一個純文本pom.xml
爲root
。據我瞭解,Artifactory的攔截什麼構建工具在本地倉庫(~/.m2
)部署
[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上獲得我的root
的pom,只有pom,並且沒有神奇生成的罐子?這可能歸結爲,我怎麼告訴Maven和/或詹金斯不要用root
罐子覆蓋我的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'? – khmarbaise
在我的問題的第二行中已經回答了這個問題:管道中的前一個構建作業執行了其他目標。爲了詳細說明,只需運行'jar:jar install:install'需要45秒,而'clean install'需要4.5分鐘,測試跳過了(測試25分鐘)。 –
爲什麼要分離這些步驟,只需在前一個管道步驟中進行部署?或者使用Jenkins做部署而不是Maven ..? – khmarbaise