在 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 service connection 来连接到您的外部 Maven 存储库。以下步骤供参考。
Go to Project settings --> Pipelines --> Click Service connections --> Click new service connection --> select Maven --> Enter the required information for your Nexus Repository.
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.
由于您只需要对外部 nexus maven 存储库进行身份验证,因此可以将 Feeds 字段留空。然后单击下方突出显示的下拉列表 select 您在上述步骤中创建的 nexus 的 maven 服务连接。
完成上述步骤后,您的 maven 任务应该能够从 nexus 下载 jar 依赖项。
我正在尝试为使用 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 service connection 来连接到您的外部 Maven 存储库。以下步骤供参考。
Go to Project settings --> Pipelines --> Click Service connections --> Click new service connection --> select Maven --> Enter the required information for your Nexus Repository.
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.
由于您只需要对外部 nexus maven 存储库进行身份验证,因此可以将 Feeds 字段留空。然后单击下方突出显示的下拉列表 select 您在上述步骤中创建的 nexus 的 maven 服务连接。
完成上述步骤后,您的 maven 任务应该能够从 nexus 下载 jar 依赖项。