【发布时间】:2019-12-02 13:23:42
【问题描述】:
我有一个 maven pom 项目,在 pom.xml 中定义了 distributionManagement 部分
<project>
...
<distributionManagement>
<repository>
<id>my-repo</id>
<url>http://nexus.my.local/repository/my-private</url>
</repository>
</distributionManagement>
</project>
在settings.xml 文件中我设置了servers 部分
<servers>
<server>
<id>my-repo</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
在 jenkins 中,我将凭据绑定到这些变量
但是做mvn clean deploy 会给我以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project XY:
Failed to deploy artifacts:
Could not transfer artifact XY:pom:1.0.0 from/to my-repo (http://nexus.my.local/repository/my-private):
Failed to transfer file: http://nexus.my.local/repository/my-private/XY-1.0.0.pom.
Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
当我在构建之前在 shell 中回显变量 ${CI_DEPLOY_USERNAME} 时,它给了我 **** 输出 -> 我认为没关系。
我还应该在哪里提供变量?我项目的settings.xml 是否在 maven deploy 命令中使用?
【问题讨论】:
标签: maven jenkins credentials maven-deploy-plugin