Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50886

Declarative pipeline with pollSCM triggers 2 builds

    XMLWordPrintable

Details

    Description

      I have a multibranch declarative pipeline with a pollSCM trigger to poll every 2 minutes. Whenever there is a change to the branch in BitBucket it triggers correctly but about 2 minutes later it triggers again. I'm not sure if this is a bug or some configuration error on my behalf.

       

      I've attached a screenshot of the duplicate builds and poll log for one of the duplicate builds. Below is the top of my declarative pipeline for reference to how I am setting it up.

      pipeline {
         agent none
         environment {
            APPVERSION = '0.1.0'
            NUGET_API_KEY = credentials('build-server-nuget-id-readonly')
         }
         triggers {
             // poll repo every 2 minute for changes
             pollSCM('*/2 * * * *')
         }
         options {
             // add timestamps to output
             timestamps()
             overrideIndexTriggers(false)
             buildDiscarder(logRotator(numToKeepStr: '10'))
             skipStagesAfterUnstable()
             durabilityHint('PERFORMANCE_OPTIMIZED')
         }
      ...
      }

       

      Attachments

        Activity

          ascheman Gerd Aschemann added a comment - - edited

          I still encounter this problem every now and then. On a public Jenkins you can see it occasionally here: https://dev.dukecon.org/jenkins/job/dukecon_pwa/job/develop/, the respective Jenkinsfile is here: https://github.com/dukecon/dukecon_pwa/blob/develop/Jenkinsfile with 

          options { 
            disableConcurrentBuilds() 
            buildDiscarder(logRotator( numToKeepStr: '5', daysToKeepStr: '5'))
          }
          
          triggers { 
            pollSCM('* * * * *')
          }
           
          ascheman Gerd Aschemann added a comment - - edited I still encounter this problem every now and then. On a public Jenkins you can see it occasionally here:  https://dev.dukecon.org/jenkins/job/dukecon_pwa/job/develop/ , the respective Jenkinsfile is here:  https://github.com/dukecon/dukecon_pwa/blob/develop/Jenkinsfile  with  options { disableConcurrentBuilds() buildDiscarder(logRotator( numToKeepStr: '5' , daysToKeepStr: '5' )) } triggers { pollSCM( '* * * * *' ) }

          I encounter this issue too. Do we have a solution for this yet? I'm using Multibranch Pipeline project and Github repostitory. We are polling every 5minutes but the build takes more than 30mins to complete.Duplicate Builds are being triggered with the same  commit ID.

          Please help me.

           

          Thank you.

          priyatham Priyatham Tadikonda added a comment - I encounter this issue too. Do we have a solution for this yet? I'm using Multibranch Pipeline project and Github repostitory. We are polling every 5minutes but the build takes more than 30mins to complete.Duplicate Builds are being triggered with the same  commit ID. Please help me.   Thank you.
          markewaite Mark Waite added a comment -

          priyatham no solution in progress and no solution proposed. We recommend that webhooks are better than polling (faster response, lighter load on the git server). See "polling must die" by Kohsuke Kawaguchi for more details. If polling is truly the only way to achieve your goal, then you might also consider setting the polling interval to be greater than the average build time.

          markewaite Mark Waite added a comment - priyatham no solution in progress and no solution proposed. We recommend that webhooks are better than polling (faster response, lighter load on the git server). See "polling must die" by Kohsuke Kawaguchi for more details. If polling is truly the only way to achieve your goal, then you might also consider setting the polling interval to be greater than the average build time.
          ganthore Mark Austin added a comment - - edited

          I'm seeing this happen with one of my teams using the multi-branch pipeline setup. Two different people are able to trigger the problem rather easily, but I can't for the life of me reproduce it, so this leads me to question if local browser configs/plugins are contributing to the problem.

          Now my use case is a little different since I don't even want polling, but I've noticed that PollSCM is switched on by default with any multibranch pipeline I setup.

          ganthore Mark Austin added a comment - - edited I'm seeing this happen with one of my teams using the multi-branch pipeline setup. Two different people are able to trigger the problem rather easily, but I can't for the life of me reproduce it, so this leads me to question if local browser configs/plugins are contributing to the problem. Now my use case is a little different since I don't even want polling, but I've noticed that PollSCM is switched on by default with any multibranch pipeline I setup.
          mfbeary Matt Beary added a comment -

          we are having this issue as well - in a Bitbucket Team project (via the Bitbucket Branch Source plugin), Jenkins is queueing a fresh build when no build has completed for the given commit rather than when no build has started.  It doesn't seem to matter whether the other builds are queued vs currently executing.

          mfbeary Matt Beary added a comment - we are having this issue as well - in a Bitbucket Team project (via the Bitbucket Branch Source plugin), Jenkins is queueing a fresh build when no build has completed for the given commit rather than when no build has started .  It doesn't seem to matter whether the other builds are queued vs currently executing.

          People

            Unassigned Unassigned
            jonathank Jonathan Kuleff
            Votes:
            6 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated: