I have 4 groovy scripts (2 - dsl.groovy scripts):
JobConfig.groovy
class JobConfig { final name JobConfig(map) { name = map['name'] } }
topLevel.groovy
import JobConfig.* def doSmthWithJobConfig(final JobConfig config) { println(config.name); }
sublevel1.dsl.groovy
GroovyShell shell = new GroovyShell() def topLevelScript = shell.parse(new File("topLevel.groovy")) def jobConfigs = [ new JobConfig(name: 'JenkinsTestDSLs'), new JobConfig(name: 'JenkinsTestDSLs2') ] jobConfigs.each { topLevelScript.doSmthWithJobConfig(it); }
sublevel2.dsl.groovy
GroovyShell shell = new GroovyShell() def topLevelScript = shell.parse(new File("topLevel.groovy")) def jobConfigs = [ new JobConfig(name: 'JenkinsTestDSLs3'), new JobConfig(name: 'JenkinsTestDSLs4') ] jobConfigs.each { topLevelScript.doSmthWithJobConfig(it); }
Now, if locally I do:
groovyc JobConfig.groovy
I do not see problems running scripts locally.
But on jenkins, even if I provide JobConfig.class in the same place where these scripts are, I cannot get it to work. I read here that I do not need to compile while JobConfig.groovy is in CLASSPATH. How do I do this with jenkins? Or is there another solution?
source share