Jenkins JobDSL multibranchPipelineJob change script path

后端 未结 4 1078
天涯浪人
天涯浪人 2021-02-18 13:04

I am trying to create a multibranchPipelineJob in jobDSL, however the Jenkinsfile is at an alternative location to the default. I have looked through the docs https://jenkinsci

4条回答
  •  情深已故
    2021-02-18 13:41

    As this question still proves popular, to do this in JCasC you can do this

    jobs:
      - script: >
          folder('common');
          multibranchPipelineJob('common/jcasc-deploy') {
            factory {
              workflowBranchProjectFactory {
                scriptPath('Jenkinsfile')
              }
            }
            branchSources {
              branchSource {
                source {
                  gitSCMSource {
                    remote('git@gitlab.com:PROJECT/REPO.git')
                    credentialsId('gitlab-key')
                    id('jcasc-deploy')
                  }
                }
              buildStrategies {
                buildAllBranches {
                  strategies {
                    skipInitialBuildOnFirstBranchIndexing()
                  }
                }
              }
            }
          }
          triggers {
            periodicFolderTrigger {
              interval('1440')
            }
          }
          configure { node ->
            node / sources / data / 'jenkins.branch.BranchSource' / source / traits {
              'jenkins.plugins.git.traits.BranchDiscoveryTrait'()
            }
          }
        }
    

提交回复
热议问题