我在哪里为Bitbucket上托管的Maven项目上的Azure DevOps管道设置Nexus凭据?

问题描述 投票:1回答:1

我正在尝试为使用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中运行?

java maven bitbucket azure-pipelines nexus
1个回答
0
投票

您可以尝试使用Maven Authenticate任务添加一个Maven service connection以连接到您的外部Maven存储库。以下步骤仅供参考。

转到项目设置-> 管道->单击服务连接->单击新服务连接->选择Maven- >输入您的Nexus存储库所需的信息。

enter image description here

然后在管道中,在Maven任务之前添加Maven Authenticate任务,以提供将在以下Maven任务中使用的外部Maven存储库的凭据。

由于只需要对外部nexus maven存储库进行身份验证,因此可以将Feeds字段保留为空白。然后单击下面突出显示的下拉列表,以选择您在上述步骤中创建的nexus的Maven服务连接。

enter image description here

完成上述步骤后,您的maven任务应该能够从nexus下载jar依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.