4
votes

I am trying to configure build.gradle with azure devops artifacts repo. It was working earlier with AZURE_ARTIFACTS credentials BUT azure recently changed the way build.gradle connects to artifacts repo

    url 'https://pkgs.dev.azure.com/dp-name/_packaging/dp-name/maven/v1'
    name 'dp-name'
        authentication {
        basic(BasicAuthentication)
   }
  }

gradle build fails with the following error

> Could not resolve all dependencies for configuration ':compileClasspath'.
   > You cannot configure authentication schemes for this repository type if no credentials are provided.

* Try:

3

3 Answers

5
votes

I had a similar issue with a multi-project build that I was able to solve with a hint on this documentation page on subprojects and plugins: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl

This is what my root build.gradle file looks like - Note: I did not have to edit the subprojects build.gradle files.

plugins {
    id "net.linguica.maven-settings" version "0.5"
}

...

repositories {
    maven {
        url 'https://pkgs.dev.azure.com/<org>/<repoId>/_packaging/platform/maven/v1'
        name '<name>'
        authentication {
            basic(BasicAuthentication)
        }
    }
}

...

subprojects {
    apply plugin: 'net.linguica.maven-settings'

    ...

}
4
votes

If it once worked but recently fails, you may need to check if the PAT is still valid. Try creating a new PAT and use it in settings.xml file to check.

enter image description here

And please make sure you use the latest setup way to configure the authentication:

1.Add this section to your build.gradle file in both the repositories and publishing.repositories containers:

maven {
    url 'https://pkgs.dev.azure.com/xxx/xxx/_packaging/xxx/maven/v1'
    name 'xxx'
    authentication {
        basic(BasicAuthentication)
    }
}

2.Add or edit the settings.xml file in ${user.home}/.m2:

<server>
  <id>looi</id>
  <username>xxx</username>
  <password>[PERSONAL_ACCESS_TOKEN]</password>
</server>
4
votes

I had the same issue. I resolved it by adding maven settings plugin:

buildscript {
...
  dependencies {
    ...
    classpath "net.linguica.gradle:maven-settings-plugin:0.5"
  }
}
apply plugin: 'net.linguica.maven-settings'

After that gradle succeed with authorization to azure feed.