Resolving failed Gradle dependencies when using the Jenkins Matrix Plugin

The issue:

 

I was asked to by a customer  to run multiple builds of a Java project, each dependant of a different set of main product Jars

 

The Jars were loaded to Artifactory with a specific version level naming convention

 

The Jenkins installation has the following Plugins installed:

The Jenkins job running the single build of the Java Project against the latest Jars had a build.gradle script with these dependencies:

 

repositories {

    maven {

        url 'http://10.0.0.82:8081/artifactory/ext-repo'

        url 'http://10.0.0.82:8081/artifactory/libs-release-local'

    }

}

 

dependencies {

    compile group: 'javax', name: 'servlet-api', version: '3.0'

    compile group: 'com.google.guava', name: 'guava', version: '12.0.1'    

compile group: 'product_api', name: 'product_api', version: '7.0.+'

    compile group: 'product', name: 'product', version: '7.0.+'

}


 

And the build ran smoothly

 

But when running the parameterized build script with these dependencies:

 

repositories {

    maven {

        url 'http://10.0.0.82:8081/artifactory/ext-repo'

        url 'http://10.0.0.82:8081/artifactory/libs-release-local'

    }

}

 

dependencies {

    compile group: 'javax', name: 'servlet-api', version: '3.0'

    compile group: 'com.google.guava', name: 'guava', version: '12.0.1'

    compile group: 'product', name: 'product', version: "$System.env.HOTFIX_VER"

    compile group: 'product', name: 'product_api', version: "$System.env.HOTFIX_VER"

}

 

The servlet-api and guava were nowhere to be found:

 

FAILURE: Build failed with an exception.

 

* What went wrong:

Could not resolve all dependencies for configuration ':compile'.

> Could not find javax:servlet-api:3.0.

 Required by:

     :7.0-hf-1.5-1310:1.0.0.37-SNAPSHOT

> Could not find com.google.guava:guava:12.0.1.

 Required by:

     :7.0-hf-1.5-1310:1.0.0.37-SNAPSHOT

 

Root cause:

 

A free-style software project Jenkins Job is not a multi-configuration project Jenkins Job.

While a free-style software project Jenkins Job incorporates the Artifcatory Plugin the multi-configuration project Jenkins Job does not, and so, the Resolution Repository setting is missing:


 

 

Solution:

 

In order to workaround the issue, the solution is to have the resolution done in the build.gradle file - specifying where the Jars can be found using  artifactUrls in the repositories definitions

 

repositories {

    maven {

        url 'http://10.0.0.82:8081/artifactory/ext-repo'

        url 'http://10.0.0.82:8081/artifactory/libs-release-local'

        artifactUrls "http://10.0.0.82:8081/artifactory/ext-repo"

        artifactUrls "http://10.0.0.82:8081/artifactory/lib-release-local"

    }

}

 

Senior DevOps Engineer

DevOps Group
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com