簡體   English   中英

如何使用Artifactory插件和Credentials插件將Jenven的Maven工件部署到Artifactory時解決401失敗?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM