Create job with values inherited from template?

275 views
Skip to first unread message

Lars Fischer

unread,
May 8, 2015, 5:43:30 AM5/8/15
to job-dsl...@googlegroups.com
Hello,

is there a way, to copy/clone a previously defined job and overwrite or add some values?
I have no groovy knowledge, so this may be a stupid question.

E.g.

def jobTemplate = mavenJob("jobTemplate") {
  jdk("1.7")
  triggers {
    cron("H   H(1-6)   *   *   *")
  }
}


def myModules = ["m1", "m2"]

for (String moduleName : myModules) {

  // create a new job based on the jobTemplate
  def childJob = c_o_p_y_o_f(jobTemplate) { // ?Is this possible?
    name{moduleName}
    // other child specific values    
  }

}


Regards,
Lars

Daniel Spilker

unread,
May 19, 2015, 9:19:42 AM5/19/15
to job-dsl...@googlegroups.com
You can use "using" to create jobs from a template, see https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-reference#using

mavenJob('maven-template') {
  jdk('1.7')
}

mavenJob('project-a') {
  using('maven-template')
  publishers {
    archiveJunit('**/target/surefire-reports/*.xml')
  }
}


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-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/1b419cb7-551a-4605-8f58-0b2a2a0235aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lars Fischer

unread,
May 27, 2015, 5:09:50 AM5/27/15
to job-dsl...@googlegroups.com
Hello Daniel,

this works like a charm.

Thank you! :)

Lars
Reply all
Reply to author
Forward
0 new messages