繁体   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