1
votes

Artifactory provides a Jenkins plugin and according to the docs it is supposed to

resolve artifacts from Artifactory and deploy artifacts and build information to Artifactory.

I published a library to Artifactory and now I'm trying to build a project that consumes that library

My Setup

build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}

Jenkins gradle build-step

Runs ./gradlew assemble

Gradle-Artifactory Integration:

Enabled, but since I only need/want artifacts to be resolved from Artifactory, I've configured my Artifactory server and resolution repository, but disabled everything else.

My build currently fails with the following error

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any version that matches com.mygroup:mylib:latest.integration.
     Searched in the following locations:
         file:/var/lib/jenkins/.m2/repository/com/mygroup/mylib/maven-metadata.xml
         file:/var/lib/jenkins/.m2/repository/com/mygroup/mylib/
         https://jcenter.bintray.com/com/mygroup/mylib/maven-metadata.xml
         https://jcenter.bintray.com/com/mygroup/mylib/
         file:/mnt/jenkins/tools/android-sdk/extras/android/m2repository/com/mygroup/mylib/maven-metadata.xml
         file:/mnt/jenkins/tools/android-sdk/extras/android/m2repository/com/mygroup/mylib/
         file:/mnt/jenkins/tools/android-sdk/extras/google/m2repository/com/mygroup/mylib/maven-metadata.xml
         file:/mnt/jenkins/tools/android-sdk/extras/google/m2repository/com/mygroup/mylib/
     Required by:
         My Job:app:1.0-SNAPSHOT

Clearly, gradle is not searching Artifactory for the artifact.

Question

How can I get the Artifactory plugin for Jenkins to tell gradle to resolve artifacts from my Artifactory server? Even just getting gradle to look there would be a start.

1

1 Answers

1
votes

Artifactory is not jcenter. If your library only deployed to Artifactory, you need to set up your build to take the dependencies from Artifactory. You have too ways to achieve it: in Jenkins and in Gradle.

Setting up Jenkins

You set up Jenkins to use Artifactory for your dependencies, using the Artifactory Jenkins Plugin.

Install the plugin, setup Artifactory server in the settings and then in job configuration check the "Resolve artifacts from Artifactory" checkbox.

Or, setting up Gradle

Another option might be instructing Gradle to use your Artifactory server as dependencies repository. Probably something like this will do the job:

repositories {
    maven {
        url "http://myartifactoryhost:80801/artifactory/libs-releases"
    }
}

Please note that you need to replace the host and the port and you might also want to change the name of the repository if you prefer to resolve the artifacts from another one (like libs-snapshots).


I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.