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

git scm poll doesn't ignore changes with pipeline

      We are using the job as attached with the groovy test.groovy file. We poll the SCM for changes but want to ignore any change that is in our jenkins-jobs git repo. This is because in a full setup we poll more repositories which do change. In the jenkins pipeline we use .* as exclude region. This does work unless we clone the same repository in our test.groovy. There we say poll=false, but the repository is polled and at the moment we make a commit to jenkins-jobs.git the job is run. With these configuration we would expect this job to never run, even when we schedule it frequrently

        1. config.xml
          2 kB
        2. test.groovy
          0.2 kB

          [JENKINS-38508] git scm poll doesn't ignore changes with pipeline

          D B added a comment - - edited

          ehaselwanter, Could you explain a bit how to use your workaround?  I'm not sure where to put DisableRemotePoll or PathRestriction.  I tried putting it under the extensions property of checkout scm but it's still polling the secondary repo.

          Update: You add them between the extensions: [] brackets.

          D B added a comment - - edited ehaselwanter , Could you explain a bit how to use your workaround?  I'm not sure where to put DisableRemotePoll or PathRestriction.  I tried putting it under the extensions property of checkout scm but it's still polling the secondary repo. Update: You add them between the extensions: [] brackets.

          Ygor Almeida added a comment - - edited

          Thanks to ehaselwanter this works for me:

          checkout(
          poll: false,
          scm: [
            $class: 'GitSCM', branches: [[name: '*/master']],
            userRemoteConfigs: [[
              url: MY_URL.git,
              credentialsId: CREDENTIALS_ID]],
            extensions: [
              [$class: 'DisableRemotePoll'],
              [$class: 'PathRestriction', excludedRegions: '', includedRegions: '*']]
          ])
          

           
          GitSCM poll does ignore changes now.
           
           

          Ygor Almeida added a comment - - edited Thanks to ehaselwanter this works for me: checkout( poll: false , scm: [ $class: 'GitSCM' , branches: [[name: '*/master' ]], userRemoteConfigs: [[ url: MY_URL.git, credentialsId: CREDENTIALS_ID]], extensions: [ [$class: 'DisableRemotePoll' ], [$class: 'PathRestriction' , excludedRegions: '', includedRegions: ' *']] ])   GitSCM poll does ignore changes now.    

          Alfredo Moreira added a comment - - edited

          Are you guys using: 
          triggers {
          pollSCM 'H/5 * * * *'
          }
          to trigger the builds? ehaselwanter ygorth
           
          I have that and it is still polling the repo I do not wan to be polled. This is my set up:
           

          // pipeline{
          //Pipeline Options
          options{
          buildDiscarder(logRotator(numToKeepStr:'5'))
          disableConcurrentBuilds()
          skipDefaultCheckout()
          }
          //define agent/node to run job on on
          agent {
          node{
          label 'windows'
          }
          }
          triggers {
          pollSCM 'H/2 * * * *'
          }
          //Stages/Build Steps
          stages{
          //Set Source Code Management of code
          stage('Set SCM'){
          steps{
          checkout(
          poll:true,
          scm: [
          $class:'GitSCM',
          branches: [[name:branch]],
          doGenerateSubmoduleConfigurations: false,
          clean:true,
          extensions: [[$class: 'DisableRemotePoll'],
          [$class: 'PathRestriction', excludedRegions: '',
          includedRegions: '*']],
          submoduleCfg: [],
          userRemoteConfigs: [[url: 'link to Repo']],
          credentialsId:'Jenkins Creds',
          ])
          }
          }
          //Pull Groovy Function Library
          stage('Load Jenkins-Code Files'){
          steps{
          dir('CI-CD'){
          checkout(
          poll:false,
          scm: [
          $class:'GitSCM',
          branches: [[name:'master']],
          clean:true,
          extensions: [
          [$class: 'DisableRemotePoll'],
          [$class: 'PathRestriction', excludedRegions: '',
          includedRegions: '*']],
          submoduleCfg: [],
          userRemoteConfigs: [[url: 'GitHub Repo']],
          credentialsId:'Jenkins Creds',
          ])
          }
          }
          }

           

          The Load Jenkins Code is the repo i do not want to poll. Like this, both repos are being polled, and if i remove trigger nothing gets polled. Any help would be much appreciated. Thanks in advance.

          Alfredo Moreira added a comment - - edited Are you guys using:  triggers { pollSCM 'H/5 * * * *' } to trigger the builds?  ehaselwanter ygorth   I have that and it is still polling the repo I do not wan to be polled. This is my set up:   // pipeline{ //Pipeline Options options{ buildDiscarder(logRotator(numToKeepStr: '5' )) disableConcurrentBuilds() skipDefaultCheckout() } //define agent/node to run job on on agent { node{ label 'windows' } } triggers { pollSCM 'H/2 * * * *' } //Stages/Build Steps stages{ //Set Source Code Management of code stage( 'Set SCM' ){ steps{ checkout( poll: true , scm: [ $class: 'GitSCM' , branches: [[name:branch]], doGenerateSubmoduleConfigurations: false , clean: true , extensions: [[$class: 'DisableRemotePoll' ], [$class: 'PathRestriction' , excludedRegions: '', includedRegions: '*' ]], submoduleCfg: [], userRemoteConfigs: [[url: 'link to Repo' ]], credentialsId: 'Jenkins Creds' , ]) } } //Pull Groovy Function Library stage( 'Load Jenkins-Code Files' ){ steps{ dir( 'CI-CD' ){ checkout( poll: false , scm: [ $class: 'GitSCM' , branches: [[name: 'master' ]], clean: true , extensions: [ [$class: 'DisableRemotePoll' ], [$class: 'PathRestriction' , excludedRegions: '', includedRegions: '*' ]], submoduleCfg: [], userRemoteConfigs: [[url: 'GitHub Repo' ]], credentialsId: 'Jenkins Creds' , ]) } } }   The Load Jenkins Code is the repo i do not want to poll. Like this, both repos are being polled, and if i remove trigger nothing gets polled. Any help would be much appreciated. Thanks in advance.

          Michael Wong added a comment -

          It seems like polling is always done if changelog is set to true (by default it does get set to true). It should work if you set both to false.

          You also might need to restart your Jenkins server to get it to work (if the job was polling before, since the cached polling baseline never gets reset).

          Michael Wong added a comment - It seems like polling is always done if changelog is set to true (by default it does get set to true). It should work if you set both to false. You also might need to restart your Jenkins server to get it to work (if the job was polling before, since the cached polling baseline never gets reset).

          sradi added a comment -

          For me, the workaround with "DisableRemotePoll" and "PathRestriction" does not work.
          Did anyone successfully use this workaround?

          Is there anybody, who plans to fix this old issue anytime soon?

          sradi added a comment - For me, the workaround with "DisableRemotePoll" and "PathRestriction" does not work. Did anyone successfully use this workaround? Is there anybody, who plans to fix this old issue anytime soon?

          sradi use the option "changelog: false", i had used the Disable with no success, but adding the changelog option fixed everything. You might have to restart Jenkins for the polling to take effect correctly and not use the cache. 

          Here is my git checkout that i dont want to be polled, this repo is cloned into the CI-CD directory inside the project:

          checkout(
          poll:false,
          changelog:false,
          scm: [
          $class:'GitSCM',
          branches: [[name:'master']],
          clean:true,
          extensions: [[$class: 'DisableRemotePoll'],
          [$class: 'PathRestriction', excludedRegions: '*']],
          userRemoteConfigs: [[url: 'GithubURL]],
          credentialsId:'creds-ID,
          ])

          And the polling will look like this:

          Started on Jan 22, 2018 9:43:15 AM Using strategy: Default [poll] Last Built Revision: Revision a2a141227f71769af6e69a0b5d1dacfb6478effe (origin/develop) > git --version # timeout=10 > git ls-remote -h

          ""Github URL"

          1. timeout=10 Found 36 remote heads on

          "Github URL"

          [poll] Latest remote head revision on refs/heads/develop is: a2a141227f71769af6e69a0b5d1dacfb6478effe - already built by 272

          no polling baseline in /Users/mcoeadm/.jenkins/jobs/pe-dev- Davita Dev - Android/workspace/CI-CD on Done. Took 0.69 sec No changes .  --> "THIS IS THE LINE THAT MAKES THE DIFFERENCE"

           

          Hopefully this helps.

          Alfredo Moreira added a comment - sradi use the option "changelog: false", i had used the Disable with no success, but adding the changelog option fixed everything. You might have to restart Jenkins for the polling to take effect correctly and not use the cache.  Here is my git checkout that i dont want to be polled, this repo is cloned into the CI-CD directory inside the project: checkout( poll:false, changelog:false, scm: [ $class:'GitSCM', branches: [ [name:'master'] ], clean:true, extensions: [ [$class: 'DisableRemotePoll'] , [$class: 'PathRestriction', excludedRegions: '*'] ], userRemoteConfigs: [ [url: 'GithubURL] ], credentialsId:'creds-ID, ]) And the polling will look like this: Started on Jan 22, 2018 9:43:15 AM Using strategy: Default [poll] Last Built Revision: Revision a2a141227f71769af6e69a0b5d1dacfb6478effe (origin/develop) > git --version # timeout=10 > git ls-remote -h ""Github URL" timeout=10 Found 36 remote heads on "Github URL" [poll] Latest remote head revision on refs/heads/develop is: a2a141227f71769af6e69a0b5d1dacfb6478effe - already built by 272 no polling baseline in /Users/mcoeadm/.jenkins/jobs/pe-dev- Davita Dev - Android/workspace/CI-CD on Done. Took 0.69 sec No changes .  --> "THIS IS THE LINE THAT MAKES THE DIFFERENCE"   Hopefully this helps.

          Aaron Ling added a comment -

          I hit this issue as well. Setting changelog to false and restarting Jenkins seems to bypass the issue.

          Aaron Ling added a comment - I hit this issue as well. Setting changelog to false and restarting Jenkins seems to bypass the issue.

          Nandlal Deshmukh added a comment - - edited

          @ehaselwanter ,  Thanks a lot, you saved me ..

           Below workaround worked for me 

          extensions: [[$class: 'DisableRemotePoll']]
          
           def scmVars1 = checkout([def scmVars1 = checkout([ $class : 'GitSCM', branches:  [[name: '*/' + "${BRANCH_PARAM}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'DisableRemotePoll']], submoduleCfg : [], userRemoteConfigs: [[url: 'https://github.com/zbcdeshmukhxys/framework.git']] ])
          

          Nandlal Deshmukh added a comment - - edited @ ehaselwanter  ,  Thanks a lot, you saved me ..  Below workaround worked for me  extensions: [[$class: 'DisableRemotePoll' ]] def scmVars1 = checkout([def scmVars1 = checkout([ $class : 'GitSCM' , branches:  [[name: '*/' + "${BRANCH_PARAM}" ]], doGenerateSubmoduleConfigurations: false , extensions: [[$class: 'DisableRemotePoll' ]], submoduleCfg : [], userRemoteConfigs: [[url: 'https: //github.com/zbcdeshmukhxys/framework.git' ]] ])

          Igor Fraa added a comment -

          According to Git plugin source 
          [$class: 'DisableRemotePoll']
          is not related to disabling polling. It is for repositories with 'ls-remote' disabled and acts as an alias for requiresWorkspaceForPolling parameter. 

          the only workaround to disable polling is to set 

          [$class: 'PathRestriction', excludedRegions: '', includedRegions: 'no/such/path/exists']

          Igor Fraa added a comment - According to Git plugin source   [$class: 'DisableRemotePoll'] is not related to disabling polling. It is for repositories with 'ls-remote' disabled and acts as an alias for requiresWorkspaceForPolling parameter.  the only workaround to disable polling is to set  [$class: 'PathRestriction' , excludedRegions: '', includedRegions: ' no/such/path/exists']

          igora setting path restrictions, as you recommended, did not work for me.

          Stephan Schultchen added a comment - igora setting path restrictions, as you recommended, did not work for me.

            Unassigned Unassigned
            jwillemsen Johnny Willemsen
            Votes:
            17 Vote for this issue
            Watchers:
            27 Start watching this issue

              Created:
              Updated: