带有 Bitbucket 分支插件的多分支管道的 DSL 种子作业抑制分支的自动构建

DSL Seed Job for Multibranch pipeline with Bitbucket branch plugin suppress auto build of branches

有一个 DSL 作业可以在 jenkins 中创建多分支管道作业,运行 Jenkins 2.107.1 带有插件:'Branch API Plugin' 2.0.18,'Bitbucket Branch Source Plugin' 2.2.10.

我找不到合适的配置函数来启用 属性 到 "Suppress automatic SCM triggering",请帮忙。

这是我的工作,但它只是在扫描分支后立即触发构建:

multibranchPipelineJob("job") {
  configure {
    it / sources / data / 'jenkins.branch.BranchSource' / source(class: 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource') {
      credentialsId('..')
      id("..")
      checkoutCredentialsId("..")
      repoOwner("owner")
      repository("my-repo")
      includes()
      excludes("PR-*")
    }
  }
}

这就是它现在的工作方式...在以下源代码的帮助下:

https://github.com/jenkinsci/bitbucket-branch-source-plugin

multibranchPipelineJob("job") {
  branchSources {
    branchSource {
      source {
        bitbucket {
          credentialsId("myid")
          repoOwner("iam")
          repository("job")                       
          traits {
            headWildcardFilter {
              includes("branchestoinclude")
              excludes("toexclude")
            }
          }
        }
      }
      strategy {
        defaultBranchPropertyStrategy {
          props {
            // keep only the last 8 builds
            buildRetentionBranchProperty {
              buildDiscarder {
                logRotator {
                  daysToKeepStr("-1")
                  numToKeepStr("8")
                  artifactDaysToKeepStr("-1")
                  artifactNumToKeepStr("-1")
                }
              }
            }
          }
        }
      }
    }
  }
  // Branch behaviour
  configure {
    def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
    traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
      strategyId(3) // detect all branches -refer the plugin source code for various options
    }
  }
  orphanedItemStrategy {
    discardOldItems {
      numToKeep(8)
    }
  }
}