Quite new to Job DSL, I am running some tests and trias.
I currently try to factorize some common job configuration part in a library I can reuse within each job.
I know how to do that with DSL, but I face out a problem with adding an env var.
I have this code which run ok :
class jobFramework {
static commonConf(dslFactory) {
dslFactory.configure { project ->
project / 'buildWrappers' {
'hudson.plugins.ws__cleanup.PreBuildCleanup'{
'deleteDirs'(false)
}
'trigger'{
'cron'('*,*,H/4,*')
}
}
project / 'logRotator' {
'daysToKeep'('10')
'numToKeep'('-1')
'artifactDaysToKeep'('12')
'artifactNumToKeep'('-1')
}
}
}
}
freeStyleJob("my_job")
{
environmentVariables {
env('TOTO','TITI')
}
jobFramework.commonConf(it)
}Now I would like to put the env var definition into the jobFramework class.But trying the following lines : project / 'environmentVariables' {
'env'('TOTO','TITI')
}
I obtain the following error :groovy.lang.MissingMethodException: No signature of method: groovy.util.NodeBuilder.env() is applicable for argument types: (java.lang.String, java.lang.String) values: [TOTO, TITI]
Possible solutions: any(), find(), any(groovy.lang.Closure), wait(), every(), dump()
at jobFramework$_commonConf_closure1$_closure4.doCall(script:20)
at jobFramework$_commonConf_closure1$_closure4.doCall(script)
at javaposse.jobdsl.dsl.MissingPropertyToStringDelegate.methodMissing(MissingPropertyToStringDelegate.groovy:39)
at javaposse.jobdsl.dsl.MissingPropertyToStringDelegate.invokeMethod(MissingPropertyToStringDelegate.groovy)
at jobFramework$_commonConf_closure1.doCall(script:19)
...
where 10 is the line number of the lines related to env vars.
So... after several trials, I am quite lost...
If someone cold help, thanks a lot !
Best Regards
J-L