Re: JobDSL : how to define build env var into a configuration class

2016-11-03 Thread JL 6BerYeti
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 jenkinsci-users+unsubscr...@googlegroups.com.
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.


Re: JobDSL : how to define build env var into a configuration class

2016-11-02 Thread Victor Martinez
Specific mailing list about Job DSL Plugin:
- https://groups.google.com/forum/#!forum/job-dsl-plugin

Cheers

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7a80a56a-ac99-404b-b320-82d1a8205ee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: JobDSL : how to define build env var into a configuration class

2016-11-02 Thread Victor Martinez
Hi J-L,

 I've just seen your jobFramework class and I guess you don't need to use 
the configure closure 
 
unless you those plugins are not supported by JobDSL, otherwise it's worth 
using the DSL syntax, for instance:
- 
https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.step.StepContext.environmentVariables

There are some interesting urls/projects:
- 
https://github.com/jenkinsci/job-dsl-plugin/wiki/Real-World-Examples#import-other-files-ie-with-class-definitions-into-your-script
- https://github.com/sheehan/job-dsl-gradle-example (this is my favourite 
one)

If you would like to use the configure closure anyway, use 
the http://job-dsl.herokuapp.com/ then you will be able to understand how 
your snippet is converted to XML and from there you could create your 
specific configure closure. the below DSL produce the same Job

freeStyleJob("my_job")
{
environmentVariables {
env('TOTO','TITI')
}
}

freeStyleJob("my_job") {
configure { project ->
def properties = project / 'properties' 
properties << EnvInjectJobProperty {
info {
propertiesContent('TOTO=TITI')
loadFilesFromMaster(false)
}
on(true)
keepJenkinsSystemVariables(true)
keepBuildVariables(true)
overrideBuildParameters(false)
contributors('')
}
}
}


Finally, if you use JobDSL version 1.46+ then you can use the autogenerated 
DSL 
 
and 
get rid off the configure closure.

I hope it helps,

Cheers

On Wednesday, 2 November 2016 17:38:50 UTC, JL 6BerYeti wrote:
>
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/ef43b886-54b1-4cb5-af09-9801063f4a1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


JobDSL : how to define build env var into a configuration class

2016-11-02 Thread JL 6BerYeti
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3150a67b-e825-453d-ac72-3a2fb2d59275%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.