Re: Capturing environment variables from template in job definition?

477 views
Skip to first unread message

Justin Ryan

unread,
Jun 19, 2013, 11:44:46 PM6/19/13
to job-dsl-plugin
Knowing when to overwrite or append to the XML is a fundamental problem with our approach. In the beginning of the project we though to append alway, but we quickly learned that it takes a lot more work to intelligently append. We then took the approach to append when possible and easy, otherwise just overwrite.  Since then I've found myself just building up jobs from scratch and not worrying about existing values in templates, essentially taking a "we leave you alone if you leave us alone" approach.

I'd be interested in hearing from the community how often templates are used (aka using() syntax) and if the manipulations are additive (adding to exist structures) or constructive (creating new structures).  

I should also note that we're pretty bad about multiple calls being made, and we could be better. Calling environmentVariables multiple times would leave the last one as the winner. When we could defer its creation, accumulating the vars as we went. Once again, that takes more work and its something we can add later if needed. We should also document this better. So, if people see one behavior or other, please add it to the docs or bring it to our attention.


On Sat, Jun 8, 2013 at 4:51 PM, Jordan Dea-Mattson <j...@dea-mattson.com> wrote:
We have environment variables which are injected via the template we will be processing in the job definition. 

When I injected additional environment variables (i.e. environmentVariables(['FOO':'BAR', 'TAR':'MAR'])) in the job definition, they overwrote rather than being added to those already injected via the template being processed.

Is there a pattern for a merging of environment variables?

If my terminology is off, please feel free to correct me. While I have some background in Java and Python, and fairly deep Ruby experience, I am definitely learning Groovy on the job.

Yours,

Jordan

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/970e13a3-9987-483d-a839-5b27a11b6d8f%40googlegroups.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Andrew Harmel-Law

unread,
Jun 20, 2013, 3:00:37 AM6/20/13
to job-dsl...@googlegroups.com
Justin,

Do you think it'd be worth putting a summary of this on the Power Moves page of the wiki?  It seems it might help folks a lot, and that might be where they would go when they experienced some of these "funnies".  I'll do it BTW, so no need to find the time.

Andrew

ceilfors

unread,
Mar 5, 2015, 8:46:59 AM3/5/15
to job-dsl...@googlegroups.com
I'm heavily using the template feature as for me this is the most essential feature of job-dsl. There will always be a job template for each job created off from the seed job. Some of the other build engineers in our company are not technical enough nor interested to write the job dsl script, so I always put what I can put to the template hence I can let the others configure it via Jenkins UI.

When I need dynamism of values (for example email recipients), I will be configuring the email notification in the template and parameterized it with EnvInject. I will then modify the environment variable in the job dsl script.

When I need dynamism of structures (for example dynamic steps), I will be constructing the structure via the job dsl instead of the template (because it's impossible to make it via template!). This scenario however is only happening in a more complex job configuration, which is not many in our Jenkins instance.

Jonathan Woods

unread,
Mar 5, 2015, 2:26:15 PM3/5/15
to job-dsl...@googlegroups.com
Hi, Justin.

We have a pretty complex set of build pipelines - multiple projects, multiple branches - and a fair amount of programming in Groovy over and above pure JobDSL.  We've found no use for templates, fwiw.

Best wishes

Jon

Joe Eaves

unread,
Jul 6, 2017, 6:33:18 AM7/6/17
to job-dsl-plugin
I'm with Jonathan, I use groovy scripting itself over templates. I create functions to generate my job definitions instead. 

The problem that brought me here is that environmentVariables still can't be called multiple times! :(
Reply all
Reply to author
Forward
0 new messages