Great !
Thanks a lot. It works !
But I hardly understand why it is so different than other confiugration 
such as ws cleaner or logrotator.

Using the Job DSL playground, it appears that a little bit simpler code is 
possible by simply avoiding default config :
def properties = project / 'properties' 
    properties << EnvInjectJobProperty {
        info {
            propertiesContent('TOTO=TITI')
            loadFilesFromMaster(false)
        }
}


Best Regards
J.L.P.

Le mercredi 2 novembre 2016 18:38:50 UTC+1, JL 6BerYeti a écrit :
>
> 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
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a1465eb9-0421-4ea0-9c6e-9b33e44a00ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to