I have 4 groovy scripts (2 are 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 get no issues with running the scripts locally.
But on jenkins even if I provide the JobConfig.class at the same place where these scripts are, I can't get it running. I read here that I don't need to do any compiling as long as JobConfig.groovy is on the CLASSPATH. How do I do that with jenkins? Or is there another solution?