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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

       

       

       

        Attachments

          Issue Links

            Activity

            p4karl Karl Wirth created issue -
            p4paul Paul Allen made changes -
            Field Original Value New Value
            Labels P4_SUPPORT
            p4karl Karl Wirth made changes -
            Description 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}
             

             
            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 P4_SUPPORT P4_VERIFY
            p4karl Karl Wirth made changes -
            Link This issue relates to JENKINS-47427 [ JENKINS-47427 ]
            p4karl Karl Wirth made changes -
            Link This issue relates to JENKINS-52066 [ JENKINS-52066 ]
            wbasupm W Basu Perforce made changes -
            Assignee Paul Allen [ p4paul ]
            wbasupm W Basu Perforce made changes -
            Labels P4_VERIFY P4_A
            wbasupm W Basu Perforce made changes -
            Link This issue is related to JENKINS-52066 [ JENKINS-52066 ]
            wbasupm W Basu Perforce made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            p4karl Karl Wirth made changes -
            Labels P4_A P4_A P4_SUPPORT
            p4karl Karl Wirth made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]

              People

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

                Dates

                Created:
                Updated:
                Resolved: