Feature Request: Going a step further with Jenkins Automation

144 views
Skip to first unread message

Steven Terrana

unread,
Jan 11, 2017, 11:32:25 PM1/11/17
to job-dsl-plugin
Hello all,

I'm currently automating the deployment of a Jenkins platform using Puppet.

Currently, as far as the Jenkins configuration via groovy and Job-DSL portion of automation goes we
  1. create seed job directly from an XML file stored in our SCM using the jenkins CLI.
  2. build the seed job using the jenkins CLI 
  3. run a groovy script through the script console that sets up tool configurations (programmatically configuring Jenkins) 

I was wondering if it would be possible to simplify this process by doing one of two things:
  1. Rather than kicking off job generation through processing Job-DSL scripts in a seed job, make it possible to process Job-DSL scripts as part of a groovy script on the groovy script console
  2. Enable you write DSL code - and then specify that you're done with Job-DSL so the jobs get created - and then you can perform additional actions with these jobs if need be. 
This would allow you to write one groovy script that configures Jenkins both from a tool/settings perspective and from a jobs perspective.

I realize that the seed job that gets generated from an XML could just contain the groovy script that also configures settings.. but i'm just thinking it would be more elegant if this could all take place from one script.


My specific use case of this is i'm creating a folder - within that folder i create a view - i set this new view as the primary view but it's not possible with Job DSL to not create the "All" view and i can't delete it programmatically because at the time of script execution - the folder doesn't actually exist yet. 

This means that i have to execute the Job-DSL that creates this folder/view and then in a next step - as part of an "execute groovy step" build step - i delete the "All" view. 


TL;DR
    It would be nice if you could specify in a Job-DSL script that you're done scripting jobs and have those jobs get created so that code moving forward could reference the generated items.
    An alternative solution would be to enable a mechanism to process Job-DSL scripts as part of a system groovy script from the Jenkins script console. 


I appreciate any feedback - perhaps what i'm trying to do is already possible. 

Thank you,
Steven




Daniel Spilker

unread,
Jan 12, 2017, 2:52:22 AM1/12/17
to job-dsl...@googlegroups.com
Hi Steven!

See this question on Stack Overflow about calling Job DSL from `init.groovy` (or a system Groovy build step): http://stackoverflow.com/q/37157188/1271460. So you do not need to create a seed job or you can create the seed job using Job DSL. This also allows to do pre/post configuration before/after executing Job DSL scripts.

In a seed job, you can also use system Groovy build steps to do pre/post configuration before/after the "Process Job DSLs" build step.

And Kohsuke started working on a system config DSL, but progress stalled. See https://github.com/jenkinsci/system-config-dsl-plugin and https://issues.jenkins-ci.org/browse/JENKINS-31094. But maybe someone can pick that up.

Regards,
Daniel


--
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-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/52ed70ea-9b7f-4601-9572-4208879cc7d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Terrana

unread,
Jan 12, 2017, 2:50:30 PM1/12/17
to job-dsl-plugin
Daniel,

I appreciate your quick reply! This is exactly what I was looking for. 

The concept of configuring jenkins as a whole through DSL as well is an exciting idea. I'll definitely take a look at how much progress has been made and see if it's a viable solution yet! 

Thanks again,
Steven
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.
Reply all
Reply to author
Forward
0 new messages