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

p4publish: workspace.manualSpec.cleanup without effect

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • p4-plugin
    • Jenkins 2.361.1, p4 plugin 1.13.0

      Hi,

      I have a p4publish in my pipeline with a workspace with manualSpec.cleanup set to true, but it seems the p4 client is not deleted after publishing. For checkout, this option works as expected, but for publish it doesn't seem to have any effect.

      Also, an explicit p4cleanup after p4publish doesn't do the trick, it just tries to delete the client used during the last sync.

      Is there any way to clean up a client created/used during publish?

      Thanks,

      Patrick

          [JENKINS-69808] p4publish: workspace.manualSpec.cleanup without effect

          Create a simple PR here, needs review and also might need to be polished, though: https://github.com/jenkinsci/p4-plugin/pull/160

          Patrick Schlangen added a comment - Create a simple PR here, needs review and also might need to be polished, though: https://github.com/jenkinsci/p4-plugin/pull/160

          Karl Wirth added a comment -

          Thanks pschlan for highlighting this.

          I have confirmed current behavior. I will let the developers know about the PR.

           

          REPRODUCTION STEPS:

          (1) Add files to //depot/cleanup/...

          (2) Create a pipeline job with following script (assumes Linux slave and P4 credential called JenkinsMaster):

          pipeline {
            agent any
            options { skipDefaultCheckout() }
            stages {
              stage("Sync") {
                steps {
                  script {
                  checkout perforce(credential: 'JenkinsMaster', 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', cleanup: true, 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/cleanup/... //${P4_CLIENT}/...')))
                      sh 'ls'  
                  }
                }
              }
              stage ("Submit") {
                steps {
                  script {
                      sh 'echo TESTING > "$(date +"%Y_%m_%d_%I_%M_%S").log"'
                      sh 'ls'
                     p4publish credential: 'JenkinsMaster', publish: submit(delete: false, description: 'Submitted by Jenkins. Build: ${BUILD_TAG}', modtime: false, onlyOnSuccess: false, paths: '', purge: '', reopen: false), workspace: manualSpec(charset: 'none', cleanup: true, name: 'jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}-submit', pinHost: false, spec: clientSpec(allwrite: false, backup: false, changeView: '', clobber: true, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '//depot/cleanup/... //${P4_CLIENT}/...'))
                     }
                }    
              }
            }
          }
           

          (3) Manually build job.

          (4) Under the 'Sync' step we see workspace cleanup:

          P4 Task: syncing files at change: 2603
          
          P4: saving built changes.
          
          P4Task: cleanup Client: jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0
          Executor number at runtime: 0
          ... p4 login -a +
          ... p4 login -s +
          ... p4 client -o jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0 +
          ... p4 info +
          ... p4 info +
          ... p4 client -o jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0 + 

          but we do not see any 'cleanup' under 'Submit':

          P4 Task: publish files to Perforce.
          ... p4 change -i +
          ... p4 change -o 2604 +
          ... pending change: 2604
          ... p4 reopen -c2604 //jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0-submit/.___ +
          ... p4 change -o 2604 +... p4 opened -Cjenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0-submit //jenkin___ +
          ... ... add //depot/cleanup/2022_10_11_10_28_08.log
          ... submitting files
          ... p4 describe -s 2604 +
          ... p4 fixes -c2604 +
          ... p4 submit -i +
          ... submitted in change: 2604
          duration: (220ms)
          
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS 

           

           

          Karl Wirth added a comment - Thanks pschlan for highlighting this. I have confirmed current behavior. I will let the developers know about the PR.   REPRODUCTION STEPS: (1) Add files to //depot/cleanup/... (2) Create a pipeline job with following script (assumes Linux slave and P4 credential called JenkinsMaster): pipeline {   agent any   options { skipDefaultCheckout() }   stages {     stage( "Sync" ) {       steps {         script {         checkout perforce(credential: 'JenkinsMaster' , 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 ', cleanup: true , 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/cleanup/... //${P4_CLIENT}/...')))             sh 'ls'           }       }     }     stage ( "Submit" ) {       steps {         script {             sh 'echo TESTING > "$(date +" %Y_%m_%d_%I_%M_%S ").log" '             sh 'ls'            p4publish credential: 'JenkinsMaster' , publish: submit(delete: false , description: 'Submitted by Jenkins. Build: ${BUILD_TAG}' , modtime: false , onlyOnSuccess: false , paths: '', purge: ' ', reopen: false ), workspace: manualSpec(charset: ' none ', cleanup: true , name: ' jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}-submit ', pinHost: false , spec: clientSpec(allwrite: false , backup: false , changeView: ' ', clobber: true , compress: false , line: ' LOCAL ', locked: false , modtime: false , rmdir: false , serverID: ' ', streamName: ' ', type: ' WRITABLE ', view: ' //depot/cleanup/... //${P4_CLIENT}/...'))            }       }         }   } } (3) Manually build job. (4) Under the 'Sync' step we see workspace cleanup: P4 Task: syncing files at change: 2603 P4: saving built changes. P4Task: cleanup Client: jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0 Executor number at runtime: 0 ... p4 login -a + ... p4 login -s + ... p4 client -o jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0 + ... p4 info + ... p4 info + ... p4 client -o jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0 + but we do not see any 'cleanup' under 'Submit': P4 Task: publish files to Perforce. ... p4 change -i + ... p4 change -o 2604 + ... pending change: 2604 ... p4 reopen -c2604 //jenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0-submit/.___ + ... p4 change -o 2604 +... p4 opened -Cjenkins-master-JENKINS-69808_-_PublishCleanupPipeline-0-submit //jenkin___ + ... ... add //depot/cleanup/2022_10_11_10_28_08.log ... submitting files ... p4 describe -s 2604 + ... p4 fixes -c2604 + ... p4 submit -i + ... submitted in change: 2604 duration: (220ms) [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS    

          Paul Allen added a comment -

          Released in 1.13.2

          Paul Allen added a comment - Released in 1.13.2

            Unassigned Unassigned
            pschlan Patrick Schlangen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: