0

I'm using the ez-template to create a template and make other jobs, based on that template. Apparently, however, the template is only applied when you manually click either the save or apply buttons. I've used the following Jenkins Job DSL code to try to achieve this:

job("job_name") {
  properties {
    templateImplementationProperty {
      exclusions(['ez-templates', 'job-params', 'disabled', 'description'])
      syncAssignedLabel(true)
      syncBuildTriggers(true)
      syncDescription(false)
      syncDisabled(false)
      syncMatrixAxis(true)
      syncOwnership(true)
      syncScm(true)
      syncSecurity(true)
      templateJobName('template')
    }
  }
}

This creates the XML for that job just fine, but it is never applied/saved/submitted. How can I achieve this functionality through the Jenkins Job DSL API?

SevenEleven
  • 2,326
  • 2
  • 32
  • 32
  • What does the console output show, after you have built the job? and what version of the Job DSL plugin do you use? I can't find that property `templateImplementationProperty` in the docs – SevenEleven Aug 04 '16 at 18:01

2 Answers2

1

Job DSL uses two Jenkins API methods to create or update jobs, Jenkins#createProjectFromXML(...) (source) and AbstractItem#updateByXml(...) (source). The first method causes a ItemListener#onCreate(...) event and the second one causes a SavableListener#onChange(...) event.

The EZ Template plugin only reacts on ItemListener#onUpdated(...) (source).

If you are using Job DSL, you do not necessarily need the EZ Template plugin as Job DSL provides it's own template mechanism, see https://jenkinsci.github.io/job-dsl-plugin/#path/job-using.

job('job_name') {
  using('template')
}

If you still want to use the EZ Template pluign, I suggest to file a feature request for the EZ Template plugin to also react on the two events mentioned above.

Links API docs:

daspilker
  • 8,154
  • 1
  • 35
  • 49
0

This behaviour is improved in ez-templates 1.3.0

drekbour
  • 2,895
  • 18
  • 28