My issue turned out was related to where I was running (Secure Development Environment) and the default Groovy / Ivy configuration that has Maven Central as the first repository by default. It would always fail because our SDE has no external access.
Being new to Groovy, I had no idea this file existed. Once I updated groovyConfig.xml to ONLY have our internally accessible repository and it works. Good luck! On Thu, Sep 17, 2015 at 2:19 PM, Joel Young <[email protected]> wrote: > I ran into the same problem. I assume you're trying to do it in a System > Groovy Script. If so, that's the problem. The System Groovy Scripts run > under the version of Groovy built into Jenkins. In my case, it's 1.8.5. > You'll probably need to run this in a non-system Groovy Script. Then you > get into the situation that I'm still trying to resolve, which is getting > the build variables and environment variables accessible by the script. > You can create a parameter file that you can fill using a System Groovy > script, then in the next build step access it. However, I'm trying to > create the properties file with a name and location specific to the build, > and am trying to figure out how to transfer the settings from the System > Groovy build step to the non-system Groovy build step > > > On Monday, August 24, 2015 at 2:29:34 PM UTC-4, Jeff Vincent wrote: >> >> 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/79330dce-15bf-4a92-85ee-f1e6d2dcf4f9%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/79330dce-15bf-4a92-85ee-f1e6d2dcf4f9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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%3DJR2zYOesbxMzqgX4Vo1e80OSt6inEQ9VtMNUFYdPuBCA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
