繁体   English   中英

如何在构建多分支管道之前合并?

[英]How to merge before build in a multi-branch pipeline?

对于简单的管道作业,我在 Additional Behaviours 下有“构建前合并”。 但是我如何在多分支管道中做到这一点? 找不到那个选项。

提前致谢。

我将在这里发布我通过代码所做的事情:

def mergeBeforeBuild() {

  // Pull the source and test a merge
  try {
    def sourceScmCheck = checkout changelog: true, poll: true, scm: [
      $class: 'GitSCM',
      branches: [[name: "origin/$sourceBranch" ]],
      doGenerateSubmoduleConfigurations: false,
      extensions: [[
        $class: 'PreBuildMerge',
        options: [
          fastForwardMode: 'FF',
          mergeRemote: 'origin',
          mergeStrategy: 'default',
          mergeTarget: "${env.target_branch}"]],
        [$class: 'UserIdentity',
          email: 'jenkins@jenkins.com',
          name: 'jenkins'
      ]],
      submoduleCfg: [],
      userRemoteConfigs: [[
        credentialsId: 'githubCredentials',
        name: 'origin',
        url: "$repoUrl"
      ]]
    ]
  } catch (error) {
    currentBuild.result = 'FAILURE'
    echo "ERROR: ${error}"
    sh 'false'
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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