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

Pipeline: Poll per change syncs to head when using 'checkout' or 'p4 sync' step.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • Jenkins 2.89.3
      P4-Plugin 1.8.10

      When using Poll per change the system will correctly run individual builds for each new changelist but if using 'p4sync' or 'checkout' steps are used they will sync to #HEAD instead of the changelist to be built.

      For example if the Jenkinsfile relies on the implicit sync that happens automatically the behavior is:

       

      Setup job with a 30 second sleep at start
      Submit CL 1, 2 ,3, 4
      Build 1 runs that syncs up to changelist 1 and reports that only CL 1 has built.
      Build 2 runs that syncs up to changelist 2 and reports that only CL 2 has built.
      Build 3 runs that syncs up to changelist 3 and reports that only CL 3 has built.
      Build 4 runs that syncs up to changelist 4 and reports that only CL 4 has built.

       

       

      If instead the implicit sync is switched off and an explicit  'p4sync' or  checkout' is used in the Jenkinsfile the behavior is:

       

      Setup job with a 30 second sleep at start
      Submit CL 1, 2 ,3, 4
      Build 1 runs that syncs up to changelist 4 but reports that only CL 1 has built.
      Build 2 runs that syncs up to changelist 4 but reports that only CL 2 has built.
      Build 3 runs that syncs up to changelist 4 but reports that only CL 3 has built.
      Build 4 runs that syncs up to changelist 4 but reports that only CL 4 has built.

       

      Reproduction Step:

      (1) Create a pipeline job with Jenkinsfile in SCM and polling build filter of 'Polling Per Change'.

      (2) Create a dummy Jenkinsfile with a sleep and submit to Perforce. For example:

      pipeline {
          //agent any
          agent{label 'MySlave'}
          //options { skipDefaultCheckout() }  
        stages {
          stage("PollPerChange") {
            steps {
              script {
                  echo "In script."
                  echo "Sleeping..."
                  sleep 30
                  //checkout perforce(credential: 'MasterServer', filter: [incremental(true)], 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}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: false, clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/pollperchange/... //jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}/...')))
                  sh 'ls'  
              }
            }
          }
        }
      }
      

      (3) Create 3 changelists in relevant path then run 'poll now' on job (customised to your environment) as it is.

      (4) Uncomment 3 lines in Jenkinsfile and submit to Perforce.

      (5) Create 3 changelists in relevant path then run 'poll now' on job.

       

       

       

          [JENKINS-51525] Pipeline: Poll per change syncs to head when using 'checkout' or 'p4 sync' step.

          Karl Wirth created issue -
          Paul Allen made changes -
          Labels New: P4_SUPPORT
          Karl Wirth made changes -
          Description Original: When using Poll per change the system will correctly run individual builds for each new changelist but if using 'p4sync' or 'checkout' steps are used they will sync to #HEAD instead of the changelist to be built.

          For example if the Jenkinsfile relies on the implicit sync that happens automatically the behavior is:

           
          {code:java}
          Setup job with a 30 second sleep at start
          Submit CL 1, 2 ,3, 4
          Build 1 runs that syncs up to changelist 1 and reports that only CL 1 has built.
          Build 2 runs that syncs up to changelist 2 and reports that only CL 2 has built.
          Build 3 runs that syncs up to changelist 3 and reports that only CL 3 has built.
          Build 4 runs that syncs up to changelist 4 and reports that only CL 4 has built.{code}
           

           

          If instead the implicit sync is switched off and an explicit  'p4sync' or  checkout' is used in the Jenkinsfile the behavior is:
           

           
          {code:java}
          Setup job with a 30 second sleep at start
          Submit CL 1, 2 ,3, 4
          Build 1 runs that syncs up to changelist 4 but reports that only CL 1 has built.
          Build 2 runs that syncs up to changelist 4 but reports that only CL 2 has built.
          Build 3 runs that syncs up to changelist 4 but reports that only CL 3 has built.
          Build 4 runs that syncs up to changelist 4 but reports that only CL 4 has built.{code}
           

           
          New: When using Poll per change the system will correctly run individual builds for each new changelist but if using 'p4sync' or 'checkout' steps are used they will sync to #HEAD instead of the changelist to be built.

          For example if the Jenkinsfile relies on the implicit sync that happens automatically the behavior is:

           
          {code:java}
          Setup job with a 30 second sleep at start
          Submit CL 1, 2 ,3, 4
          Build 1 runs that syncs up to changelist 1 and reports that only CL 1 has built.
          Build 2 runs that syncs up to changelist 2 and reports that only CL 2 has built.
          Build 3 runs that syncs up to changelist 3 and reports that only CL 3 has built.
          Build 4 runs that syncs up to changelist 4 and reports that only CL 4 has built.{code}
           

           

          If instead the implicit sync is switched off and an explicit  'p4sync' or  checkout' is used in the Jenkinsfile the behavior is:

           
          {code:java}
          Setup job with a 30 second sleep at start
          Submit CL 1, 2 ,3, 4
          Build 1 runs that syncs up to changelist 4 but reports that only CL 1 has built.
          Build 2 runs that syncs up to changelist 4 but reports that only CL 2 has built.
          Build 3 runs that syncs up to changelist 4 but reports that only CL 3 has built.
          Build 4 runs that syncs up to changelist 4 but reports that only CL 4 has built.{code}
           

          *Reproduction Step:*

          (1) Create a pipeline job with Jenkinsfile in SCM and polling build filter of 'Polling Per Change'.

          (2) Create a dummy Jenkinsfile with a sleep and submit to Perforce. For example:
          {code:java}
          pipeline {
            //agent any
              agent{label 'MySlave'}
            //options { skipDefaultCheckout() }  
            stages {
              stage("PollPerChange") {
                steps {
                  script {
                      echo "In script."
                      echo "Sleeping..."
               sleep 30
                      //checkout perforce(credential: 'MasterServer', filter: [incremental(true)], 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}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: false, clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/pollperchange/... //jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}/...')))
                      sh 'ls'  
                  }
                }
              }
            }
          }
          {code}
          (3) Create 3 changelists in relevant path then run 'poll now' on job (customised to your environment) as it is.

          (4) Uncomment 3 lines in Jenkinsfile and submit to Perforce.

          (5) Create 3 changelists in relevant path then run 'poll now' on job.

           

           

           
          Labels Original: P4_SUPPORT New: P4_VERIFY
          Karl Wirth made changes -
          Link New: This issue relates to JENKINS-47427 [ JENKINS-47427 ]
          Karl Wirth made changes -
          Link New: This issue relates to JENKINS-52066 [ JENKINS-52066 ]

          Paul Allen added a comment - - edited

          The Jenkinsfile in my test setup (I also set Poll per Change on the Pipeline Script from SCM):

          pipeline {
           agent any 
           stages {
            stage('Build') { 
             steps {
              checkout perforce(credential: 'phooey', filter: [incremental(true)], populate: autoClean(quiet: true), workspace: streamSpec(format: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}', streamName: '//deep/subX/main'))
             }
            }
           }
          } 

          //deep/subX/main is a stream in a different location to the Jenkinsfile defined in the Pipeline Script from SCM (also a stream at //deep/projA/main).  Changes in //deep/subX/main seem to sync as expected with Poll per Change.

          Changes to //deep/projA/main are not seen by polling as Lightweight checkout was selected (client is thrown away and p4 print is used so no have list). 

          Paul Allen added a comment - - edited The Jenkinsfile in my test setup (I also set Poll per Change on the Pipeline Script from SCM): pipeline { agent any stages { stage( 'Build' ) { steps { checkout perforce(credential: 'phooey' , filter: [incremental( true )], populate: autoClean(quiet: true ), workspace: streamSpec(format: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}' , streamName: ' //deep/subX/main' )) } } } } //deep/subX/main is a stream in a different location to the Jenkinsfile defined in the Pipeline Script from SCM (also a stream at //deep/projA/main).  Changes in //deep/subX/main seem to sync as expected with Poll per Change. Changes to //deep/projA/main are not seen by polling as Lightweight checkout was selected (client is thrown away and p4 print is used so no have list). 
          W Basu Perforce made changes -
          Assignee New: Paul Allen [ p4paul ]
          W Basu Perforce made changes -
          Labels Original: P4_VERIFY New: P4_A
          W Basu Perforce made changes -
          Link New: This issue is related to JENKINS-52066 [ JENKINS-52066 ]
          W Basu Perforce made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

            p4paul Paul Allen
            p4karl Karl Wirth
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: