Hi,

How does one import a custom class from within a system groovy script, when 
this class is in a file in the workspace?

The workspace is obtained like this:

def thr = Thread.currentThread();
def currentBuild = thr?.executable;
def workspace = currentBuild.getModuleRoot().absolutize().toString();

Then the class is loaded like this:
String roots = [workspace+"/path/to/file"]
def engine   = new GroovyScriptEngine(roots)
def JDU      = engine.loadScriptByName('JenkinsDescriptionUtils.groovy')

Then jenkins crashes with:
FATAL: Cannot open URL: 
file:/path/to/jenkins/%5B/path/to/slaves/myhost/workspace/job-name/path/to/file%5DJenkinsDescriptionUtils.groovy

I looks like Jenkins has its own classloader and prepends its own path to 
the path I want, thus breaking it.

I tried the simple solution, that is using a plain import statement, but 
that too did not work.

Thanks,
Martin


-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to