问题描述
开发通过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
问题定位及解决
- 首先排查了代码的pom文件,检查pom文件中的distributionManagement部分的配置,检查发现配置正确。
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>${nexusReleaseUrl}</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>${nexusSnapshotUrl}</url>
</snapshotRepository>
</distributionManagement>
- 然后查看编译结果,这里发现有些问题,父pom文件中定义了软件版本为1.0.1,但是子模块中又分别定义了子模块的版本为1.0.0, 同时检查nexus私服,发现私服上已经有了版本为1.0.0的jar包,所以,让开发回去重新梳理pom文件中的模块的版本号。
- 开发修改版本号后再次提交代码,发现报同样的错误。 检查nexus私服,发现父pom已经上传私服,删除私服上的父pom文件,再次上传。
- 上传仍然失败。
- 重新逐一检查打包的版本信息,没有问题。但是一运行deploy就报错。于是回头检查releases的配置,发现有个配置可能有影响:
- 尝试将disable redeploy改成了Allow redeploy, 然后运行job重新上传,可以上传。问题解决。