【问题标题】:maven deploy + nexus failed on bad requestmaven deploy + nexus 因错误请求而失败
【发布时间】:2014-09-08 12:37:23
【问题描述】:

我的构建过程遇到了一些问题。

构建完成正常,Jenkins 开始将文件上传到 nexus。一切正常,但由于某种原因它失败了,最奇怪的部分是提到的不上传的文件实际上是上传的,我可以在 nexus 中找到它。

这是输出:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] pn-parent
[INFO] pn-domain
[INFO] pn-infra
[INFO] pn-config
[INFO] datalink-repository
[INFO] pn-service
[INFO] pn-backend
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building pn-parent 0.0.707
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:pom:4.11 has been relocated to junit:junit:pom:4.11
[INFO] 
[INFO] --- maven-jar-plugin:2.5:jar (default-cli) @ pn-parent ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /var/lib/jenkins/jobs/webapps-server-side-release/workspace/pn-parent/target/pn-parent-0.0.707.jar
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-cli) @ pn-parent ---
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/0.0.707/pn-parent-0.0.707.pom          
     Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/0.0.707/pn-parent-0.0.707.pom (15 KB at 111.6 KB/sec)
Downloading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/maven-metadata.xml
     Downloaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/maven-metadata.xml (21 KB at 1036.9 KB/sec)
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/maven-metadata.xml
     Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-parent/maven-metadata.xml (21 KB at 864.7 KB/sec)
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building pn-domain 0.0.707
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:pom:4.11 has been relocated to junit:junit:pom:4.11
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-cli) @ pn-domain ---
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-cli) @ pn-domain ---
      Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-domain/0.0.707/pn-domain-0.0.707.jar    
      Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/0.0.707/datalink-repository-0.0.707.jar (624 KB at 7606.1 KB/sec)
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/0.0.707/datalink-repository-0.0.707.pom
2/4 KB       
4/4 KB   
      Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/0.0.707/datalink-repository-0.0.707.pom (4 KB at 93.0 KB/sec)
Downloading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/maven-metadata.xml
       Downloaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/maven-metadata.xml (21 KB at 1382.8 KB/sec)
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/maven-metadata.xml
       Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/datalink-repository/maven-metadata.xml (21 KB at 1037.8 KB/sec)
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building pn-service 0.0.707
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:pom:4.11 has been relocated to junit:junit:pom:4.11
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-cli) @ pn-service ---
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-cli) @ pn-service ---
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn-service/0.0.707/pn-service-0.0.707.jar     
       Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.war (1247 KB at 19480.3 KB/sec)
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.pom      
       Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.pom (11 KB at 376.2 KB/sec)
Downloading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/maven-metadata.xml  
        Downloaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/maven-metadata.xml (21 KB at 1213.1 KB/sec)
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/maven-metadata.xml  
       Uploaded: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/maven-metadata.xml (21 KB at 1031.7 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] pn-parent ................................... SUCCESS [  1.081 s]
[INFO] pn-domain ................................... SUCCESS [  0.696 s]
[INFO] pn-infra .................................... SUCCESS [  0.295 s]
[INFO] pn-config ................................... SUCCESS [  0.275 s]
[INFO] datalink-repository ............................... SUCCESS [  0.390 s]
[INFO] pn-service .................................. SUCCESS [  0.475 s]
[INFO] pn-backend .................................. SUCCESS [  1.043 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.234 s
[INFO] Finished at: 2014-07-17T14:31:30+00:00
[INFO] Final Memory: 19M/206M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "release" could not be activated because it does not exist.
using global settings config with name mycompany-global-dev-maven-settings
[workspace] $ /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.1.1/bin/mvn -gs /tmp/global-settings8833627416958413984.xml deploy:deploy-file -Durl=http://maven.mycompany.com:8081/nexus/content/repositories/releases/ -DrepositoryId=mycompany.repository -DpomFile=pn-parent/Backend/pom.xml -Dfile=pn-parent/Backend/target/pn-backend.war
[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] 'usePluginRegistry' is deprecated and has no effect. @ /var/lib/jenkins/.m2/settings.xml
[WARNING] 
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom ---
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.war
...
Uploading: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.pom
2/11 KB          
4/11 KB   
6/11 KB   
8/11 KB   
10/11 KB   
11/11 KB   

       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD FAILURE
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time: 1.928 s
       [INFO] Finished at: 2014-07-17T14:31:33+00:00
       [INFO] Final Memory: 6M/142M
       [INFO] ------------------------------------------------------------------------
       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.mycompany.pn:pn-backend:war:0.0.707 from/to mycompany.repository (http://maven.mycompany.com:8081/nexus/content/repositories/releases/): Failed to transfer file: http://maven.mycompany.com:8081/nexus/content/repositories/releases/com/mycompany/pn/pn-backend/0.0.707/pn-backend-0.0.707.war. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
         [ERROR] 
         [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
         [ERROR] Re-run Maven using the -X switch to enable full debug logging.
          [ERROR] 
          [ERROR] For more information about the errors and possible solutions, please read the following articles:
         [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
         Build step 'Conditional steps (multiple)' marked build as failure
         [locks-and-latches] Releasing all the locks
         [locks-and-latches] All the locks released
         [Current build status] check if current [FAILURE] is worse or equals then [SUCCESS] and better or equals then [SUCCESS]
         Run condition [Current build status] preventing perform for step [Record JaCoCo coverage report]
        Description set: 
        Start to submit Nexus scheduled tasks.
        Submitting... [id: 36, name: release-build, type: Rebuild Maven Metadata Files]
        End to submit Nexus scheduled tasks successfully.
         Notifying upstream projects of job completion
        Finished: FAILURE

【问题讨论】:

  • 你解决过这个问题吗?我遇到了 exact 同样的问题。我认为也许 maven 正在尝试两次上传工件,但我不确定为什么或如何阻止它(并且重新部署在我的存储库中被禁用,因为它们应该是)。
  • @AlienBishop 这里有同样的问题,在我的情况下是由于两个不同的 maven 插件,maven-source-plugin 和 maven-assembly-plugin。看到这个问题stackoverflow.com/questions/28407831/…修复maven-assembly-plugin错误
  • @AlienBishop 对于 maven-source-plugin 错误,请在此处查看此答案 stackoverflow.com/questions/4251488/…,在我的情况下,我必须同时进行这两个修复,因为 maven-deploy-plugin 已经负责上传工件。

标签: maven build jenkins nexus


【解决方案1】:

我的一位同事在 maven 尝试两次上传工件时遇到了同样的问题。 我们在论坛中找到了一些帮助,链接如下。 Bae 的回答对我们有用:

尝试运行 mvn -Prelease-profile help:effective-pom。你会找到 maven-source-plugin 有两个执行部分

[...]

要解决此问题,请查找您使用过的所有位置 maven-sources-plugin 并确保使用“id” attach-sources 使其与发布配置文件相同。然后 这些部分将被合并。最佳实践说要得到 一致性,您需要在项目的根 pom 中配置它 在 build > pluginManagement 中,而不是在您的子 poms 中。在孩子 您只需在您要使用的 build > plugins 中指定的 pom maven-source-plugin 但你没有提供任何执行。

Nexus accepts upload but says it failedMaven release plugin fails : source artifacts getting deployed twice

【讨论】:

  • 请在答案正文中包含链接中的所有相关信息。当链接腐烂/移动/死亡或以其他方式变得不可用时,仅链接的答案往往会失去价值。
  • 答案已编辑。感谢 EWit 和 Raf 的反馈。
【解决方案2】:

快照和发布冲突也会导致 400 错误请求。您尝试更新的项目可能是 pom 中这样的快照:

<version>0.0.1-SNAPSHOT</version>

而 settings.xml 中的存储库拒绝快照。解决方案:

<version>0.0.1</version>

反过来也会发生这种情况:尝试将发布(version 没有快照)版本部署到快照存储库。

【讨论】:

    【解决方案3】:

    我也遇到过这个问题。在我的情况下,我将 Nexus 存储库策略配置为接受发布工件,但我实际上是在将快照工件推送到存储库。由于我想要快照存储库,因此我只是更改了策略,一切都很好。

    【讨论】:

      【解决方案4】:

      这也发生在我身上。就我而言,我正在部署一个发布版本。要解决此问题,请确保版本号在 Nexus 中尚不存在。如果是多模块项目,还要检查子模块的版本。

      【讨论】:

        猜你喜欢
        • 2015-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多