I'm trying to write a Groovy script that will query our Sonatype Nexus OSS Maven repository for information about a given artifact (war file) that was just deployed as part of a build. I then want to set Jenkins job parameters so I can use them in subsequent steps in the job.
My script is currently using the groovyx.net.http.RESTClient and works in stand-alone mode see script below, but when I run it as a Groovy System Script it throws the following: FATAL: org/apache/ivy/core/settings/IvySettings java.lang.NoClassDefFoundError <http://stacktrace.jenkins-ci.org/search?query=java.lang.NoClassDefFoundError>: org/apache/ivy/core/settings/IvySettings If I remove the @GrabResolver, @Grapes and @Grab directives, it throws this error: ERROR: Build step failed with exception org.codehaus.groovy.control.MultipleCompilationErrorsException <http://stacktrace.jenkins-ci.org/search?query=org.codehaus.groovy.control.MultipleCompilationErrorsException>: startup failed: Script1.groovy: 2: unable to resolve class groovyx.net.http.RESTClient @ line 2, column 1. import groovyx.net.http.RESTClient ^ How do I specify a dependency for a Groovy script so I can import and use a given class? Thanks! ##Script: @GrabResolver(name='myrepo', root='http://nexus.mycompany.com/nexus/content/groups/myrepo/', m2Compatible='true') @Grapes([ @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1') ]) import groovyx.net.http.RESTClient import hudson.model.* try { def client = new RESTClient( 'http://nexus.mycompany.com/nexus/service/local/artifact/maven/resolve' ) println "Get w/ path" def resp = client.get( query : ['r': 'myrepo', 'g': 'mygroupid', 'a': 'myartifactid', 'v': '1.0-SNAPSHOT', 'e': 'jar'], headers: ['Accept': 'application/json', "Content-Type": 'application/json'] ) def json = resp.getData() def version = json.data.version def url = json.data.repositoryPath def sha1 = json.data.sha1 printf( "Found: version: '%s' url: '%s' sha1: '%s'", version, url, sha1) } catch (Exception ex) { println ex.getMessage() } -- Jeff Vincent See my LinkedIn profile at: http://www.linkedin.com/in/rjeffreyvincent -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPJK9%3DKTFETsSQFNJNC3xGAQ_m0dgAjcJ_Td%2BanaZ%2BpUsbovfw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
