簡體   English   中英

在 Bitbucket 上托管的 Maven 項目上,我在哪里設置 Azure DevOps 管道的 Nexus 憑據?

[英]Where do I set the Nexus credentials for an Azure DevOps pipeline on a Maven project hosted on Bitbucket?

我正在嘗試為使用 Maven 的 Java 項目創建一個簡單的管道。 我的項目的 .jar 依賴項都托管在受密碼保護的在線 Nexus 上。 我正在構建的源代碼托管在 Bitbucket 上。

我似乎無法找到如何告訴管道將哪些憑據用於 Nexus。

這是我的 Maven 任務結果:

Downloaded from central: xxx (34 kB at 1.3 MB/s)
Downloading from nexus: xxx
Downloading from central: xxx
Downloading from nexus: xxx
Downloading from central: xxx
Downloading from nexus: xxx
Downloading from central: xxx 949 B

Downloaded from central: xxx (949 B at 45 kB/s)
Downloading from nexus: xxx
Downloading from central: xxx
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.979 s
[INFO] Finished at: 2020-01-16T19:17:43Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project webconfigurable: Could not resolve dependencies for project com.fenplast:webconfigurable:jar:1.3.0: Failed to collect dependencies at org.jscience:com.netappsid.org.jscience:jar:3.2.0: Failed to read artifact descriptor for org.jscience:com.netappsid.org.jscience:jar:3.2.0: Could not transfer artifact org.jscience:com.netappsid.org.jscience:pom:3.2.0 from/to nexus (https://repository.fenplast.net/repository/public): Authentication failed for https://repository.fenplast.net/repository/public/org/jscience/com.netappsid.org.jscience/3.2.0/com.netappsid.org.jscience-3.2.0.pom 401 Unauthorized -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The process '/usr/share/apache-maven-3.6.3/bin/mvn' failed with exit code 1
Could not retrieve code analysis results - Maven run failed.
No test result files matching /home/vsts/work/1/s/**/surefire-reports/TEST-*.xml were found, so publishing JUnit test results is being skipped.
##[error]Build failed.
Finishing: Maven 

它說身份驗證失敗且未經授權。 當我從我自己的機器在本地運行構建時,它確實可以工作,因為我的 .m2 文件夾中有一個 settings.xml 文件,其中包含憑據,但如何使其從 Azure DevOps 工作?

您可以嘗試使用Maven Authenticate任務添加一個 Maven 服務連接來連接到您的外部 Maven 存儲庫。 以下步驟供參考。

轉到項目設置-->管道--> 單擊服務連接--> 單擊新服務連接--> 選擇Maven --> 輸入 Nexus 存儲庫所需的信息。

在此處輸入圖片說明

然后在你的管道加入Maven的身份驗證任務Maven任務之前做出規定,這將在以下Maven任務中使用的外部Maven倉庫的憑證。

由於您只需要對外部 nexus maven 存儲庫進行身份驗證,因此您可以將Feeds字段留空。 然后單擊下面突出顯示的下拉列表,為您在上述步驟中創建的 nexus 選擇 Maven 服務連接。

在此處輸入圖片說明

完成上述步驟后,您的 maven 任務應該能夠從 nexus 下載 jar 依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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