I have recently added jobs to both add a managed script, and call the same managed script from within several jobs. The jobs work as expected when called from jenkins, however when calling './gradlew test' I get the following error:
Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException'
at spock.lang.Specification.noExceptionThrown(Specification.java:118)
at com.rally.devops.jenkins.job.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:27)
Caused by: javaposse.jobdsl.dsl.DslScriptException: (BuildReleaseLib.groovy, line 62) managed script with name 'semver' not found
The test looks like:
class JobScriptsSpec extends Specification {
@Unroll
void 'test script #file.name'(File file) {
given:
JobManagement jm = new MemoryJobManagement()
when:
DslScriptLoader.runDslEngine file.text, jm
then:
noExceptionThrown()
where:
file << jobFiles
}
static List<File> getJobFiles() {
List<File> files = []
new File('jobs').eachFileRecurse(FileType.FILES) {
if (it.name.endsWith('.groovy')) {
files << it
}
}
files
}
}