【问题标题】:Azure build pipeline unable to download the dependences from azure artifact,Azure 构建管道无法从 azure artifact 下载依赖项,
【发布时间】:2021-05-29 09:37:04
【问题描述】:

我正在尝试在 azure devops 服务器上创建构建管道,我的构建管道能够从 Azure Artifact 下载依赖项

2021-03-02T05:45:24.8329366Z [INFO] ------------------------------------------------------------------------
2021-03-02T05:45:24.8329608Z [INFO] Total time:  02:31 min
2021-03-02T05:45:24.8330187Z [INFO] Finished at: 2021-03-02T05:45:24Z
2021-03-02T05:45:24.8330469Z [INFO] ------------------------------------------------------------------------
2021-03-02T05:45:24.8330824Z [ERROR] Failed to execute goal on project myapplication-commons-lib: Could not resolve dependencies for project com.myapplication.mdm.commons:myapplication-commons-lib:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.tibco.ebx.core:ebx-lib:jar:5.9.10: Failed to read artifact descriptor for com.tibco.ebx.core:ebx-lib:jar:5.9.10: Could not transfer artifact com.tibco.ebx.core:ebx-lib:pom:5.9.10 from/to myapp-snapshots (https://myapplication.pkgs.visualstudio.com/_packaging/myapp-snapshots/maven/v1): Authentication failed for https://myapplication.pkgs.visualstudio.com/_packaging/myapp-snapshots/maven/v1/com/tibco/ebx/core/ebx-lib/5.9.10/ebx-lib-5.9.10.pom 401 Unauthorized -> [Help 1]
2021-03-02T05:45:24.8331113Z [ERROR] ```


YAML Pipeline
[![enter image description here][1]][1]


[![enter image description here][2]][2]


  [1]: https://i.stack.imgur.com/L34oP.png

YAML from pipeline 

- task: Maven@3
  displayName: 'Code Compilation'
  inputs:
    mavenPomFile: '$(System.DefaultWorkingDirectory)/solution/core/build/maven/pom.xml'
    options: '-s $(System.DefaultWorkingDirectory)/solution/core/build/maven/settings.xml'
    goals: package
    mavenAuthenticateFeed: true    

【问题讨论】:

  • 不允许您(m 401 Unauthorized - 访问给定的存储库)... myworld.pkgs.visualstudio.com ???
  • 哦,有什么办法可以解决这个问题

标签: java maven build azure-devops azure-artifacts


【解决方案1】:

....401 未经授权

401 错误是身份验证错误。

在调用 Maven 任务之前添加Maven Authenticate task。 Maven Authenticate 任务可以为当前用户的 settings.xml 文件中的 Azure Artifacts 源和外部 Maven 存储库提供凭据。

如果您的 azure 工件在同一个 Collection 中,您可以直接在下拉列表中选择相应的提要。

如果你的是外部 azure artifacts(例如 Azure Devops Service),你需要在 Porject Settings -> Service Connections 中创建一个服务连接(maven)。

更新:

如果您无法使用 Maven Authenticate 任务,您可以尝试以下步骤来使用 Settings.xml 文件。

第一步:创建一个 Setting.xml 文件。

您可以导航到 Azure Devops Service -> Artifacts -> Connect to feed -> Maven

Step2:在 Azure Devops Server 中,您可以将 settings.xml 保存到路径

%USERPROFILE%\.m2\settings.xml

您可以参考this doc

另一方面,当您向 Maven 任务添加选项时。

例如:

- task: Maven@3
  displayName: 'Maven pom.xml'
  inputs:
   ...
    options: '-s filepath/settings.xml'

【讨论】:

  • 步骤引用了版本 '0' 中不存在的任务 'MavenAuthenticate'。 - task: MavenAuthenticate@0 displayName: 'Maven Authenticate' inputs: artifactsFeeds:
  • 如果您无法使用此任务,您可以尝试手动创建 settings.xml 文件。请参考我的更新,
  • 我在setting.xml文件中添加了详细信息
  • 从错误消息中,您需要定义一个特定的文件路径而不是使用 filepath/settings.xml 。文件路径需要具体。如果 settings.xml 存在于 repo 的根目录,你可以使用$(build.sourcesdirectory)/ settings.xml
  • 我已更新问题,我已更改路径,YAML 已在“问题”选项卡中更新,
猜你喜欢
  • 1970-01-01
  • 2021-02-26
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 2020-04-03
  • 2022-08-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多