Help: Running a Groovy Script containing @GrabResolver and @Grab hangs...

1,377 views
Skip to first unread message

Jeff

unread,
Aug 25, 2015, 5:35:15 PM8/25/15
to jenkins...@googlegroups.com
I'm here grovelling for some help.

I have a simple Groovy script that needs to import the RESTClient like so:

@GrabResolver(name='myrepo', root='http://nexus.mycompany.com/nexus/content/groups/myrepo/')
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1')

import groovyx.net.http.RESTClient

println "Create RESTClient"

I've tried running as a "Groovy System Script", "Groovy Script" and directly in the Scriptler script manager.  If I Remove the @GrabResolver/@Grab directives, it runs but obviously I can't use RESTClient.

If I include the @Grab and other directives, it just hangs.  I can copy the exact command and run it from the shell and it works fine.  It just doesn't work when Jenkins runs it.  

What am I doing wrong?  This should NOT be this difficult.

Thanks!

--
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

Victor Martinez

unread,
Aug 27, 2015, 5:56:33 PM8/27/15
to Jenkins Users
AFAIK grab is not supported and you could add those dependencies.(jars) in the classpath

Further details:
http://stackoverflow.com/questions/14889948/running-groovy-script-on-jenkins

Cheers

Jeff

unread,
Aug 27, 2015, 7:12:34 PM8/27/15
to jenkins...@googlegroups.com
Thanks...I just got this working today and found that it was due to my environment.  Our Jenkins runs in a Secure Development Environment with no external access.  Being new to Groovy/Grape/etc. I didn't realized that it had a default list of repositories it searched when specifying the @Grab statement and thought it was only trying to check our internal repository that I specified.  

I found that I needed a custom grapeConfig.xml that ONLY had our internal repository listed and it started working.

Disclaimer:  The use case I'm testing is NOT a "Groovy system script" but a regular Groovy script.  I was initially going to try to make a system script so I could interact with the Jenkins job and inject additional environment variables/parameters, but decided to just to it all in the Groovy script and it's working great!



--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9765d6ae-2c14-4d06-9334-ca6827c6ce23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages