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

Pipeline 'poll' option in checkout ignored if using libraries for sync

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: p4-plugin
    • Labels:
    • Environment:
      Jenkins 2.73.2
      p4-plugin 1.7.7
    • Similar Issues:

      Description

      The 'checkout' step can have a poll true or false option. If used in a jenkinsfile P4-Jenkins respects this. If it appears in a global library, the poll false option is ignored and polling still occurs on the non poll checkout.

       

      Reproduction steps:

      (1) Create a Groovy library with the 2 function. One that polls, one that does not.

       

      package org.foo;
      
      def testNoPoll ()
      {
      echo "In library - test No Poll..."
      checkout poll: false, scm: perforce(credential: 'JenkinsMasterSuper', populate: autoClean(delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', threads: '4'], pin: '', quiet: true, replace: true, tidy: false), workspace: manualSpec(charset: 'none', name: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, spec: clientSpec(allwrite: false, backup: false, clobber: false, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/no-poll/... //jenkins-${NODE_NAME}-${JOB_NAME}-src2/...')))
      }
      
      def testPoll ()
      {
      echo "In library - test Poll..."
      checkout perforce(credential: 'JenkinsMasterSuper', populate: autoClean(delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', threads: '4'], pin: '', quiet: true, replace: true, tidy: false), workspace: manualSpec(charset: 'none', name: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, spec: clientSpec(allwrite: false, backup: false, clobber: false, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/project1/main/... //jenkins-${NODE_NAME}-${JOB_NAME}-src1/...')))
      }
      
      return this;
      
      

      (2) Create a Jenkinsfile that calls the functions. For example:

       

       

      @Library('my-shared-library')
      import org.foo.lib.*
      
      pipeline {
        agent { label 'master' }
        stages {
          stage("Repro") {
            steps {
              script {
                 def z = new org.foo.lib()
                 z.testFunc()
                 z.testPoll ()
                 z.testNoPoll ()
              }
            }
          }
        }
      }
      
      

      (3) Setup polling to run every minute.

       

      (4) Submit a change in folder //depot/project1/main/...

      (5) Wait 2 minutes.

      (6) Build was triggered.

      (7) Submit change in //depot/no-poll/...

      (8) Wait 2 minutes.

      (9) Buld was triggered again when it should not have been triggered.

       

       

        Attachments

          Activity

          Hide
          wluo Wei Luo added a comment - - edited

          Hi Karl,

          I am using same version of Jenkins and P4 plugin and very similar shared lib and pipelineJob.

          Here is error when I tried to run the job. Have you seen this error?

           
          hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: perforce.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[credential:6e6c9271-a04f-4795-b4b8-xxx, populate:@forceClean(have=false,parallel=

          {enable=true, minbytes=1024, minfiles=1, threads=4}

          ,pin=,quiet=true), ...]]
          Possible solutions: call(java.lang.String, java.lang.String), call(java.lang.String, java.lang.String, java.lang.String), wait(), any(), wait(long), main([Ljava.lang.String
          at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
          Please advise,

           

          Thanks

          Show
          wluo Wei Luo added a comment - - edited Hi Karl, I am using same version of Jenkins and P4 plugin and very similar shared lib and pipelineJob. Here is error when I tried to run the job. Have you seen this error?   hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: perforce.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[credential:6e6c9271-a04f-4795-b4b8-xxx, populate:@forceClean(have=false,parallel= {enable=true, minbytes=1024, minfiles=1, threads=4} ,pin=,quiet=true), ...]] Possible solutions: call(java.lang.String, java.lang.String), call(java.lang.String, java.lang.String, java.lang.String), wait(), any(), wait(long), main([Ljava.lang.String at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58) Please advise,   Thanks
          Hide
          jayspang Jay Spang added a comment - - edited

          I'm seeing this bug as well. My pipeline checks out from 2 separate streams: The 1st is my app's source code, the 2nd is just various deployment tools that are synced from a shared library. My job is doing what I've come to call "runaway polling", where every time it polls, it thinks there's a new change and builds the project again.

          Here is the code I'm using for the second checkout: (trimmed down for readability)

          checkout changelog: false, poll: false, scm: perforce( populate: syncOnly(), workspace: streamSpec(name: jenkins-${NODE_NAME}-${JOB_NAME}-deploy-scripts) )

          And despite this, the last lines of the polling log contain this:

          P4: Polling on: master with:jenkins-master-jobName-deploy-scripts
          Done. Took 0.65 sec
          Changes found

          I don't know why it's trying to poll even though I explicitly said not to, and I don't know why the polling is exiting immediately claiming it found changes, but the combination of this is resulting in "runaway polling".

          Show
          jayspang Jay Spang added a comment - - edited I'm seeing this bug as well. My pipeline checks out from 2 separate streams: The 1st is my app's source code, the 2nd is just various deployment tools that are synced from a shared library. My job is doing what I've come to call "runaway polling", where every time it polls, it thinks there's a new change and builds the project again. Here is the code I'm using for the second checkout: (trimmed down for readability) checkout changelog: false, poll: false, scm: perforce( populate: syncOnly(), workspace: streamSpec(name: jenkins-${NODE_NAME}-${JOB_NAME}-deploy-scripts) ) And despite this, the last lines of the polling log contain this: P4: Polling on: master with:jenkins-master-jobName-deploy-scripts Done. Took 0.65 sec Changes found I don't know why it's trying to poll even though I explicitly said not to, and I don't know why the polling is exiting immediately claiming it found changes, but the combination of this is resulting in "runaway polling".
          Hide
          p4paul Paul Allen added a comment -

          Hi Karl Wirth, please can you check this using different workspace names. Thanks, Paul

          Show
          p4paul Paul Allen added a comment - Hi Karl Wirth , please can you check this using different workspace names. Thanks, Paul
          Hide
          p4paul Paul Allen added a comment -

          Closing - need more detail.  Global Library update in release 1.9.3 my change behaviour. Please reopen if required.

          Show
          p4paul Paul Allen added a comment - Closing - need more detail.  Global Library update in release 1.9.3 my change behaviour. Please reopen if required.

            People

            • Assignee:
              p4karl Karl Wirth
              Reporter:
              p4karl Karl Wirth
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: