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

PollSCM triggers jobs even if there are no changes jenkinsfile declarative

    XMLWordPrintable

Details

    Description

       I'm using the github organization folder plugin to discover branches and pull requests dynamically. The discovery of new branches work as expected, but I want to reduce the time of discovering of new PR's and new commits for the specific repositories(by default is 1 day). For that I defined triggers { pollSCM('H/10 * * * *')} in the jenkinsfile(declarative) for some branches in some repos. I'm behind a firewall, so webhooks are not an option. However, the job triggers every 10 minutes in all the branches and PR's(until accepted) even if there are no changes after building once(it saves the trigger definition).

      According to the triggers documentation, it should run only if there are changes.

      I'm using this because GitSCM is not supported in the trigger definition. It would be super nice to have it in fact.

       

      Any ideas in how to deal with this would be great/

      Attachments

        Activity

          Same issue with Jenkins ver 2.107 LTS
          GitLab Multibranch plugin
           

          whitediver Sergey Arbuzov added a comment - Same issue with Jenkins ver 2.107 LTS GitLab Multibranch plugin  
          rathneesh Rathneesh T added a comment -

          Is there any work around available for this issue?

          rathneesh Rathneesh T added a comment - Is there any work around available for this issue?

          We saw this issue too (Jenkins ver 2.190.1)

          In our case, it turned out to be caused by the Jenkinsfile referring to a shared lib version (using @Library annotation) that was not at the HEAD of the shared lib repo.

          Even when there were no changes on the main repo, the PollSCM trigger would detect changes on the shared lib repo, and trigger a new build (using the annotated shared lib version as expected) on each poll.

          We worked around the issue by removing the pollSCM trigger from the Jenkinsfile, and instead configured the (multibranch) job with "Periodically if not otherwise run" in the "Scan Multibranch Pipeline Triggers" section.

          sss_secomea Svenning Sørensen added a comment - We saw this issue too (Jenkins ver 2.190.1) In our case, it turned out to be caused by the Jenkinsfile referring to a shared lib version (using @Library annotation) that was not at the HEAD of the shared lib repo. Even when there were no changes on the main repo, the PollSCM trigger would detect changes on the shared lib repo, and trigger a new build (using the annotated shared lib version as expected) on each poll. We worked around the issue by removing the pollSCM trigger from the Jenkinsfile, and instead configured the (multibranch) job with "Periodically if not otherwise run" in the "Scan Multibranch Pipeline Triggers" section.
          harisekhon Hari added a comment -

          I've experienced this issue too but only in a Multibranch pipeline after triggering a branch manually it continued to deploy every 10 even though it showed no changes on the git branch (which was filtered via a tight anchored regex), the regular single branch pipelines are fine.

          Removing this from my Jenkinsfile solved the problem (luckily this is for feature environments and I am not relying on this one auto-deploying on any changes like my main environments):

           

           // backup to catch GitHub -> Jenkins webhook failures
           triggers {
             pollSCM('H/10 * * * *')
           }
          

           

          harisekhon Hari added a comment - I've experienced this issue too but only in a Multibranch pipeline after triggering a branch manually it continued to deploy every 10 even though it showed no changes on the git branch (which was filtered via a tight anchored regex), the regular single branch pipelines are fine. Removing this from my Jenkinsfile solved the problem (luckily this is for feature environments and I am not relying on this one auto-deploying on any changes like my main environments):   // backup to catch GitHub -> Jenkins webhook failures triggers {   pollSCM( 'H/10 * * * *' ) }  

          People

            vlatombe Vincent Latombe
            clvx Luis Ibarra
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: