Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

azure devops - gradle authentication

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:

like image 300
SunilS Avatar asked Dec 11 '22 01:12

SunilS


2 Answers

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'

    ...

}
like image 153
Josh Johanning Avatar answered Jan 14 '23 16:01

Josh Johanning


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.

like image 22
bsvtag Avatar answered Jan 14 '23 17:01

bsvtag