Gradle tries to resolve form plugins.gradle.org even though I've added repositories to my buildscript section


(Salim Fadhley) #1

I need to change my build so that everything is resolved from our internal Artifactory.

Can you help me fix this build so that it never tries to access an external repo for plugins or any other kind of dependency?

When I run my build I get the following error. This suggests that Gradle 4.x is still trying to resolve plugins from the wrong location:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\workspace\pipeline_library\build.gradle' line: 20

* What went wrong:
Error resolving plugin [id: 'org.jenkins-ci.jpi', version: '0.22.0']
> Could not GET 'https://plugins.gradle.org/api/gradle/4.0.1/plugin/use/org.jenkins-ci.jpi/0.22.0'.
   > plugins.gradle.org

The build file in it’s entirety is:

buildscript {
    repositories {
        maven {
            url "http://repo.bigco.com:8081/artifactory/plugins-release"
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }

    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
    }


}

plugins {
    id "org.jenkins-ci.jpi" version "0.22.0"
}

allprojects {
    apply plugin: "com.jfrog.artifactory"
}

sourceSets {
    main {
        groovy {
            srcDirs 'vars'
            srcDirs 'src'
        }

    }
    test {
        groovy {
            srcDirs 'tests'
        }
    }
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

repositories {
    maven {
        url "http://repo.bigco.com:8081/artifactory/virtual-java"
    }

}

dependencies {

    jenkinsPlugins(

    )
    compile(
            [group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.11'],
            [group: 'org.jenkins-ci.main', name: 'jenkins-core', version: '2.46.3'], // LTS versions only plz
            [group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-scm-step', version: '2.3'],
            [group: 'org.jenkins-ci.plugins.workflow', name:'workflow-cps', version:'2.36', ext:'jar'],
            [group: 'org.jenkins-ci.plugins.workflow', name:'workflow-support', version:'2.13', ext:'jar'],
            [group: 'org.jenkins-ci.plugins', name:'git', version:'3.3.0', ext:'jar']

    )

    testCompile(
            [group:'junit', name:'junit', version:'4.12']
    )
}

(Mark Vieira) #2

@salimfadhley, please see my response in the other topic. You need to use the apply plugin: rather than plugins { } syntax in this case.


(Mark Vieira) #3