Jenkins发布jar包到nexus私服报Return code 400 ReasonPhrase Bad Request

问题描述

开发通过jenkins发布jar包到nexus私服,报如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy (default-deploy) on project typhon: ArtifactDeployerException: Failed to deploy artifacts: Could not transfer artifact cn.bjca.footstone:typhon:pom:1.0.1 from/to releases (http://example.nexus.com/repository/releases/): Failed to transfer file: http://example.nexus.com/repository/releases/cn/bjca/footstone/typhon/1.0.1/typhon-1.0.1.pom. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy (default-deploy) on project typhon: ArtifactDeployerException

问题定位及解决

  1. 首先排查了代码的pom文件,检查pom文件中的distributionManagement部分的配置,检查发现配置正确。
 <distributionManagement>
        <repository>
            <id>releasesid>
            <name>Nexus Release Repositoryname>
            <url>${nexusReleaseUrl}url>
        repository>
        <snapshotRepository>
            <id>snapshotsid>
            <name>Nexus Snapshot Repositoryname>
            <url>${nexusSnapshotUrl}url>
        snapshotRepository>
distributionManagement>
  1. 然后查看编译结果,这里发现有些问题,父pom文件中定义了软件版本为1.0.1,但是子模块中又分别定义了子模块的版本为1.0.0, 同时检查nexus私服,发现私服上已经有了版本为1.0.0的jar包,所以,让开发回去重新梳理pom文件中的模块的版本号。
  2. 开发修改版本号后再次提交代码,发现报同样的错误。 检查nexus私服,发现父pom已经上传私服,删除私服上的父pom文件,再次上传。
  3. 上传仍然失败。
  4. 重新逐一检查打包的版本信息,没有问题。但是一运行deploy就报错。于是回头检查releases的配置,发现有个配置可能有影响:
  5. Jenkins发布jar包到nexus私服报Return code 400 ReasonPhrase Bad Request_第1张图片
  6. 尝试将disable redeploy改成了Allow redeploy, 然后运行job重新上传,可以上传。问题解决。

你可能感兴趣的:(持续集成,maven,jar,jenkins,maven)