9
votes

I'm trying to get to the Artifactory Gradle plugin working to publish to my local Artifactory instance.

I have the latest version (default install) running at localhost:8081/artifactory. I can verify this with access via a webbrowser.

However, with my bare minimum example .. I am getting a "Context URL cannot be found error

Note that I have specified all the mandatory required Artifactory configurations settings - (as indicated on the Artifactory Gradle WebPage) .. including the Context URL.

buildscript {
  repositories{ maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' } }
  dependencies{ classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.0.12'}
}

apply plugin: 'artifactory'

artifactory {
  contextUrl = 'http://localhost:8081/artifactory'   //The base Artifactory URL if not overridden by the publisher/resolver
  publish {
    repository {
      repoKey = 'integration-libs'   //The Artifactory repository key to publish to
      username = 'admin'          //The publisher user name
      password = 'password'
    } 
  }
  resolve {
    repository {
      repoKey = 'libs-releases'  //The Artifactory (preferably virtual) repository key to resolve from
    }
  }
}
1
Which version of Gradle do you use?noamt
Also, in case this might be a bug, can you try to specify the context URL in both the publish and resolve section?noamt
Latest version of Gradle (milestone 9) .. along with the corresponding artifactory plugin.vicsz
This works fine for me with milestone 9 and 1.0 final. The error message I get is "Context URL cannot be empty" if I don't define contextUrl. This message seems to be different from yours. Do you have your full source code on GitHub or some other repository? Is is a single or multi-module project?Benjamin Muschko

1 Answers

5
votes

This looks like a weird bug and I'm not sure what causes it. I get it in some of my gradle build files but others seem to work fine. I fixed it by defining the contextUrl again inside the publish element, so your script will now look like:

artifactory {
  contextUrl = 'http://localhost:8081/artifactory'   //The base Artifactory URL if not overridden by the publisher/resolver
  publish {
    contextUrl = 'http://localhost:8081/artifactory' // <- this is the fix
    repository {
      repoKey = 'integration-libs'   //The Artifactory repository key to publish to
      username = 'admin'          //The publisher user name
      password = 'password'
    } 
  }
  resolve {
    repository {
      repoKey = 'libs-releases'  //The Artifactory (preferably virtual) repository key to resolve from
    }
  }
}

You might also have to define it again inside the resolve element.