首页 > 解决方案 > 向 Azure Artifacts Maven 验证 Gradle

问题描述

我想对 Azure DevOps Artifacts 的 Azure 管道进行身份验证,对此我vstsFeedId很方便。该项目基于 Gradle

在本地,它通过创建个人访问令牌并使用~/.m2/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id><id>
      <username><username>
      <password><password>
    </server>
  </servers>
</settings>

摇篮

repositories {
    mavenCentral()
    maven {
        url ''
        name ''
        authentication {
            basic(BasicAuthentication)
        }
    }
}

但是,当我上网到管道时,Gradle 无法获取依赖项,因为未设置身份验证

FAILURE:构建失败并出现异常。

* What went wrong:
Execution failed for task ':compileJava'.
> Failed to notify dependency resolution listener.
   > Could not resolve all dependencies for configuration ':detachedConfiguration1'.
      > You cannot configure authentication schemes for this repository type if no credentials are provided.
   > Could not resolve all dependencies for configuration ':detachedConfiguration2'.
      > You cannot configure authentication schemes for this repository type if no credentials are provided.

我发现Maven 任务mavenAuthenticateFeed有一个可能有用的属性,而Gradle 任务没有

如何向我自己的 Azure DevOps Artifacts 存储库验证 Gradle?

标签: javaazuregradle

解决方案


看起来就这么简单。

使用MavenAuthenticate任务

      - task: MavenAuthenticate@0
        inputs:
          artifactsFeeds: ''

推荐阅读