jenkins 多分支管道中的分支索引会触发额外的构建,该构建已由 poll SCM 构建

Muh*_*Haq 7 triggers jenkins jenkins-pipeline multibranch-pipeline

我有一个多分支管道。我在 jenkinsFile 属性中配置了触发器:

pipelineTriggers([pollSCM('H/2 * * * *')])])
Run Code Online (Sandbox Code Playgroud)

多分支管道被配置为定期“扫描多分支管道触发器”。预期行为:仅在通过 jenkinsFile 配置的构建触发器上触发构建。

我们正在使用

詹金斯:2.107.1

git 插件:3.8.0

管道多分支:2.17

小智 2

我想我们无法阻止构建触发器的扫描。但我们的构建应该能够识别并停止额外的构建。

// execute this before anything else, including requesting any time on an agent
    if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
      print "INFO: Build skipped due to trigger being Branch Indexing"
      currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
      return
    }
Run Code Online (Sandbox Code Playgroud)

来源:https ://www.jvt.me/posts/2020/02/23/jenkins-multibranch-skip-branch-index/