Copying existing item Jenkins, using Job DSL plugin

246 views
Skip to first unread message

Shwetha Hadimani

unread,
Mar 9, 2016, 6:16:44 AM3/9/16
to job-dsl-plugin
While creating a New Item in Jenkins through UI, we have an option to "Copy existing Item". I want to be able to do the same by using Job DSL plugin.
I tried the copyArtifacts method. But its not copying the item. My copyArtifacts code is below

    job(jobName){
        steps{
          copyArtifacts('template_job'){
            includePatterns('config.xml', '*.properties')
      }
    }
Am I going wrong with this code, or is there a different way to copy existing item using Job DSL plugin.

Victor Martinez

unread,
Mar 9, 2016, 8:02:16 AM3/9/16
to job-dsl-plugin
You mean, you wanted to create a new Freestyle job, Matrix or so based on another Job? If that's the case, correct me if I'm wrong, you won't be able to use JobDSL unless you code your template job.

You can run some other system groovy script to clone jobs programmatically, but IMO, if you go for a Configuration as Code paradigm, it's worth modelling those jobs via some code .

Cheers
Reply all
Reply to author
Forward
0 new messages