简体   繁体   中英

How to create multi-branch project with Jenkins DSL plugin?

Is it possible to create multi-branch project with https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin ?

I want to define Groovy DSL configuration in Jenkins file under Git branch. I'd like to have similar UI as with https://wiki.jenkins-ci.org/display/JENKINS/Workflow+Plugin , eg:

  • job-name(multi-branch DSL project - not sure it exists)
    • master (folder)
      • job 1 from master DSL
      • job 2 from master DSL
    • feature/branch1 (folder)
      • job 1 from feature/branch1 DSL
      • job 2 from feature/branch1 DSL

This is tracked a JENKINS-31671 . There is an open pull request and I hope to get this merged for the next release.

In the meantime you could use a custom build of the Job DSL plugin, built from the pull request. Or you can use a configure block to adapt the job config XML to the multibranch plugin. There is an example that shows how to change the project type. That has to be adapted to the multibranch plugin.

job('example') {
  configure { project ->
    project.name = 'org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject'

    // adapt the XML to the multibranch project type
    ...
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM