![](/img/trans.png)
[英]rtMavenRun() artifactory plugin not using credentials configured in jenkins
[英]How can I resolve a 401 failure when deploying a Maven artifact from Jenkins to Artifactory using the Artifactory Plugin and the Credentials Plugin?
我使用Jenkins构建一个Maven项目。
我有Jenkins Credentials插件和Jenkins Artifactory插件。
我在Credentials配置中添加了Artifactory凭据。
我已将Artifactory插件配置为使用凭据并设置了服务器URL。 测试连接工作并报告它已找到服务器。
我的项目的POM指定repository
的正确Artifactory路径和distributionManagement部分中的snapshotsRepository
。
我的Jenkins项目构建配置为执行mvn deploy
。
在我的本地构建中,从我的开发机器,我可以部署到Artifactory服务器(我已在settings.xml
配置了凭据。
但是,在我的Jenkins工作中,我想使用Artifactory插件和Credentials int Credentials插件。 当我建立时,我得到以下内容
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://xxxxx/artifactory/libs-release-local
Uploading: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.war
Uploading: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.pom
Notifying upstream projects of job completion
Join notifier requires a CauseAction
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
和以下堆栈跟踪
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project querynator:
Failed to deploy artifacts: Could not transfer artifact xxx:war:3.01 from/to dwCentral (http://xxxxx/artifactory/libs-release-local):
Failed to transfer file: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.war.
Return code is: 401, ReasonPhrase: .
这向我表明问题在于凭证,特别是因为我可以从我的开发箱(使用settings.xml中的凭据)部署,但不能从Jenkins部署。
我尝试过部署新版本。 我尝试过部署快照。 这不是版本问题。
我怎么解决这个问题? 我该如何进一步排除故障?
在Jenkins中使用Artifactory插件时,不应在主构建任务中使用mvn deploy
。 它使用Maven Deploy插件,因此将尝试使用settings.xml文件中存储的凭据。
相反,使用mvn install
作为主构建任务,并设置一个新的构建后任务以将工件部署到存储库。
这允许您定义要使用的服务器,存储库位置和凭据。
假设您已正确配置凭据。 如果您已经部署了版本,请将xyz
说成一次。 执行命令
mvn deploy
同样的版本也会导致
返回码为:401,ReasonPhrase:未经授权。
您可以尝试将版本更新为从未部署过的xya
,该作业应该运行正常。
更多来自Maven Lifecycle Basics的文档
deploy
- 在构建环境中完成,将最终包复制到远程存储库以与其他开发人员和项目共享。
并假设你了解什么是Maven快照,为什么我们需要它? 并且同意这样一个事实:一旦项目被共享,不应该为消费者随时改变,不允许同一版本的部署阶段不止一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.