title: Duplicate builds triggered on Jenkins multibranch pipeline
body: <p>We are seeing duplicate builds triggered on Jenkins multibranch pipeline projects.  Builds are normally triggered using push notifications from Bitbucket using this plugin: <a href="https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview" rel="noreferrer">https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview</a></p>
  
  <p>However, we are now seeing 'double' builds for some reason.  If you look at the 2 builds that are triggered, one is triggered by a 'commit notification', and the other is triggered by 'Branch Indexing'.</p>
  
  <p><strong><em>What is causing the branch indexing, and why is it triggering a build?  We are not adding or deleting branches, it's just a normal commit/push.</em></strong></p>
  
  <p>To make it more complicated, it's not happening all the time.  At one point I thought it was only happening after merges, but that's not the case.  Also, one way to stop it seems to be by deleting the build history for a job (which obviously isn't ideal).</p>
  
  <p>We are setting properties on the job from the pipeline script, but only to discard old builds:</p>
  
  <pre><code>properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '20'))])
  </code></pre>
  
  <p>Another source of confusion seems to be if one should have polling enabled (with no interval) in order for push notifications to work for the Git plugin.  The documentation for the Git plugin indicates this is required, and indeed seems to be for 'normal' pipeline builds, but doesn't seem to be required for multibranch pipeline builds.  <strong><em>Is this correct?</em></strong>  From the Jenkins Git Plugin wiki:</p>
  
  <blockquote>
    <p>This will scan all the jobs that:</p>
    
    <p>Have Build Triggers > Poll SCM enabled.  No polling Schedule is
    required. Are configured to build the repository at the specified URL
    Are configured to build the optionally specified branches or commit ID
    For jobs that meet these conditions, polling will be immediately
    triggered.  If polling finds a change worthy of a build, a build will
    in turn be triggered.</p>
  </blockquote>
  
  <p>We are using Bitbucket 4.8.4 and Jenkins 2.30 (and all the latest pipeline plugins).</p>