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

I'm trying to create a simple Pipeline for a Java project that uses Maven.我正在尝试为使用 Maven 的 Java 项目创建一个简单的管道。 The .jar dependencies of my project are all hosted on an online Nexus that is password protected.我的项目的 .jar 依赖项都托管在受密码保护的在线 Nexus 上。 The sources I am building are hosted on Bitbucket.我正在构建的源代码托管在 Bitbucket 上。

I can't seem to find how to tell the pipeline what credentials to use for Nexus.我似乎无法找到如何告诉管道将哪些凭据用于 Nexus。

This is my maven task result:这是我的 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 

It says Authentication failed and Unauthorized.它说身份验证失败且未经授权。 When I run a build from my own machine locally it does work because I have a settings.xml file in my .m2 folder with the credentials but how do I make it work from Azure DevOps?当我从我自己的机器在本地运行构建时,它确实可以工作,因为我的 .m2 文件夹中有一个 settings.xml 文件,其中包含凭据,但如何使其从 Azure DevOps 工作?

You can have a try using Maven Authenticate task add a maven service connection to connect to your external maven repositories.您可以尝试使用Maven Authenticate任务添加一个 Maven 服务连接来连接到您的外部 Maven 存储库。 Below steps is for reference.以下步骤供参考。

Go to Project settings --> Pipelines --> Click Service connections --> Click new service connection --> select Maven --> Enter the required information for your Nexus Repository.转到项目设置-->管道--> 单击服务连接--> 单击新服务连接--> 选择Maven --> 输入 Nexus 存储库所需的信息。

在此处输入图片说明

Then in your pipeline Add Maven Authenticate task before your Maven task to provides credentials for the external Maven repositories which will be used in the following maven task.然后在你的管道加入Maven的身份验证任务Maven任务之前做出规定,这将在以下Maven任务中使用的外部Maven仓库的凭证。

Since you only need authentication for external nexus maven repositories, you can leave Feeds field blank.由于您只需要对外部 nexus maven 存储库进行身份验证,因此您可以将Feeds字段留空。 And Then click below highlighted dropdown list to select the maven service connection for nexus you created in above steps.然后单击下面突出显示的下拉列表,为您在上述步骤中创建的 nexus 选择 Maven 服务连接。

在此处输入图片说明

When you finish above steps, your maven task should be able to download jar dependencies from nexus.完成上述步骤后,您的 maven 任务应该能够从 nexus 下载 jar 依赖项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 用于 Java 项目的 DevOps 管道,带有自托管代理 - Azure DevOps Pipeline for Java Project with self hosted agent Azure DevOps Pipeline 中的 Maven 构建错误 - Maven build error in Azure DevOps Pipeline Azure DevOps Maven 构建管道 - 将构建 ID 添加到清单文件 - Azure DevOps Maven Build PIpeline - Add build id to the Manifest File 使用 azure DevOps 管道将自定义 maven 工件/包 (*.jar) 发布到 Azure 工件 - Publish custom maven artifact/package (*.jar) to Azure artifact using azure DevOps pipeline 从 pom.xml 从 Java Maven 项目在 Z3B06ADACCEC858ZEDEFBBC66 管道中获取版本 - Get the version from pom.xml from a Java Maven project in Bitbucket pipeline Azure DevOps maven 任务配置文件 - Azure DevOps maven task profile 在Azure DevOps管道生成上收到此错误“无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” - getting this error “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” on Azure DevOps pipeline build 我如何修复Eclipse项目,其中在项目下以及“ Maven Dependencies”文件夹下都列出了Maven依赖项? - How do I fix Eclipse project where maven dependencies are listed right under project but also under 'Maven Dependencies' folder? 从自定义的 nexus 存储库制作 Maven 项目 - Make maven project from custom nexus repositories 使用Nexus Repository OSS 3创建Maven项目[离线] - Create Maven Project with Nexus Repository OSS 3 [offline]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM