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

Polling build filters should ignore leading whitespace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • p4-plugin
    • 1.17.1
      P4D - ANY

      The following polling build filter will fail to exclude files submitted to 'Folder' from polling because there is leading whitespace before the filter path:

                  filter: [viewFilter('''//depot
                                        -//depot/Folder1/ignorme.txt
                                        -//depot/Folder1''')],  

      The paths on the second and third line have to be flush with the start of the line. For example:

                  filter: [viewFilter('''//depot
      -//depot/Folder1/ignorme.txt
      -//depot/Folder1''')],   

      Reproduction Steps:

      1 - Create a Perforce server with a depot called depot.

      2 - Create a credential called JenkinsMaster.

      3 - Create the following pipeline job:

      pipeline {
        agent any
        options { skipDefaultCheckout() }
        stages {
          stage("Test") {
            steps {
              script {
                  echo "In script."
                  checkout perforce(credential: 'JenkinsMaster',
                     filter: [viewFilter('''//depot
                                            -//depot/Folder1/ignorme.txt
                                            -//depot/Folder1''')], 
                     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', cleanup: false, name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: true, changeView: '', clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamAtChange: '', streamName: '', type: 'WRITABLE', view: '//depot/... //${P4_CLIENT}/...')))
                       echo "A fake build step."
              }
            }
          }
        }
      } 

      4 - Build the job once.

      5 - Add the Poll Now plugin to Jenkins.

      6 - Click Poll Now - No job is started.

      7 - Add and submit the file "//depot/Folder1/x1".

      8 - Click Poll Now - Job is started.

      9 - Edit the job to take out the whitepace from the viewFilter:

      pipeline {
        agent any
        options { skipDefaultCheckout() }
        stages {
          stage("Test") {
            steps {
              script {
                  echo "In script."
                  checkout perforce(credential: 'JenkinsMaster',
                     filter: [viewFilter('''//depot
      -//depot/Folder1/ignorme.txt
      -//depot/Folder1''')], 
                     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', cleanup: false, name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}', pinHost: false, spec: clientSpec(allwrite: false, backup: true, changeView: '', clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamAtChange: '', streamName: '', type: 'WRITABLE', view: '//depot/... //${P4_CLIENT}/...')))
                       echo "A fake build step."
              }
            }
          }
        }
      }   

      10 - Build the job once.

      11 - Click Poll Now - No job is started.

      12 - Add and submit the file "//depot/Folder1/x2".

      13 -  Click Poll Now - Job is not started proving the whitespace was the cause of the incorrect build.

      Note - If this is not fixed it should be documented.

       

       

            Unassigned Unassigned
            p4karl Karl Wirth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: