Branch Indexing in jenkins multibranch pipeline triggers extra build, which is already built by poll SCM Branch Indexing in jenkins multibranch pipeline triggers extra build, which is already built by poll SCM jenkins jenkins

Branch Indexing in jenkins multibranch pipeline triggers extra build, which is already built by poll SCM


I guess we can not stop the build trigger from scanning. But our build should be able to identify and stop the additional build.

// 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    }

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