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

Let user specify p4 workspace root in manual config

      Please note that in this issue the term "workspace" in p4 overlaps with the same term in jenkins. I'll try to be clear which I mean.

      While the p4 plugin lets the user manually configure the p4 workspace, it does not let the user specify the p4 workspace root. The plugin automatically uses the jenkins workspace directory as the p4 root.

      This is a problem because it means that the user cannot "automatic cleanup and sync" or "forced cleanup and sync" without destroying every file in the jenkins workspace. This is not desirable if we are using multiple SCMs, or other configurations where we only want the p4 plugin to clean up the p4 tree.

          [JENKINS-47005] Let user specify p4 workspace root in manual config

          Karl Wirth added a comment - - edited

          Possible workarounds:

          1. Replace contents of Jenkinsfile with a simple non instruction so that no real build is performed.
          2. Remove all access to the branch for the Jenkins user through Perforce protections.
          3. JENKINS-47066
          4. If using pipleline you can use the 'ws' directive:
                stage("SyncMyWorkspace") {
                  steps {
                     ws('/var/lib/jenkins/XXXXX/KarlTest/') {
                p4sync charset: 'none', credential: 'JenkinsMasterAdminUser', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', populate: autoClean(delete: true, modtime: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', threads: '4'], pin: '', quiet: true, replace: true, tidy: false), source: depotSource('//depot/test/...')
                echo "DONE"
                       }
                  }
                }
            

           

          Karl Wirth added a comment - - edited Possible workarounds: Replace contents of Jenkinsfile with a simple non instruction so that no real build is performed. Remove all access to the branch for the Jenkins user through Perforce protections. JENKINS-47066 If using pipleline you can use the 'ws' directive: stage( "SyncMyWorkspace" ) { steps { ws( '/ var /lib/jenkins/XXXXX/KarlTest/' ) { p4sync charset: 'none' , credential: 'JenkinsMasterAdminUser' , format: 'jenkins-${NODE_NAME}-${JOB_NAME}' , populate: autoClean(delete: true , modtime: false , parallel: [enable: false , minbytes: '1024' , minfiles: '1' , threads: '4' ], pin: '', quiet: true , replace: true , tidy: false ), source: depotSource(' //depot/test/...') echo "DONE" } } }  

          Neil Stewart added a comment -

          I'd like to see this as well. Our Jenkins workspace is stored on network storage that is backed up. I need to sync multiple branches and run multiple builds on these - each build is around 200MB of synced data and a final build output of around 1GB. Scaling this across all builds and branches can rapidly reach 100GB. We don't want these branches stored in the Jenkins workspace as the resulting branches would be subject to daily backup when they don't need to be.

          The old "Perforce Plugin" allowed us to do this as it didn't mess with the client spec or change the root. But obviously given that plugin is not supported I'd prefer to use the official P4 plugin.

          Ideally the "Manual workspace" option would have a checkbox to reuse the existing root set for the workspace (and only set it if it also has to create the workspace).

          Neil Stewart added a comment - I'd like to see this as well. Our Jenkins workspace is stored on network storage that is backed up. I need to sync multiple branches and run multiple builds on these - each build is around 200MB of synced data and a final build output of around 1GB. Scaling this across all builds and branches can rapidly reach 100GB. We don't want these branches stored in the Jenkins workspace as the resulting branches would be subject to daily backup when they don't need to be. The old "Perforce Plugin" allowed us to do this as it didn't mess with the client spec or change the root. But obviously given that plugin is not supported I'd prefer to use the official P4 plugin. Ideally the "Manual workspace" option would have a checkbox to reuse the existing root set for the workspace (and only set it if it also has to create the workspace).

          Neil Stewart added a comment - - edited

          Hmm, a bit more digging has thrown up JENKINS-45999 - perhaps the method in that will work for me, although that bug specifically mentions streams (we don't use them) and Jenkins pipelines (which I don't know anything about yet )

          Also, something I read elsewhere suggested that SCM polling doesn't work if you only map the jenkinsfile, so that would be another issue (we want to kick off Jenkins build when anyone submits changes).

          Neil Stewart added a comment - - edited Hmm, a bit more digging has thrown up JENKINS-45999 - perhaps the method in that will work for me, although that bug specifically mentions streams (we don't use them) and Jenkins pipelines (which I don't know anything about yet ) Also, something I read elsewhere suggested that SCM polling doesn't work if you only map the jenkinsfile, so that would be another issue (we want to kick off Jenkins build when anyone submits changes).

          Punith C added a comment -

          This is an interesting feature which gives me more control over where I want to keep my source code and not necessarily under Jenkins installation.

          As a workaround every times I had to fetch the client and update the client root before proceeding to populate the workspace. 

          Punith C added a comment - This is an interesting feature which gives me more control over where I want to keep my source code and not necessarily under Jenkins installation. As a workaround every times I had to fetch the client and update the client root before proceeding to populate the workspace. 

          Guy Catz added a comment -

          We would also like to see that coming. We need to sync to different drives and therefore must update the root folder. The lack of that prevents us from working smoothly with the p4 plugin.

          Guy Catz added a comment - We would also like to see that coming. We need to sync to different drives and therefore must update the root folder. The lack of that prevents us from working smoothly with the p4 plugin.

          Karl Wirth added a comment -

          Comments from JENKINS-62123:

           
          In the P4Jenkins plugin, please add the functionality to "checkout to subdirectory" when defining either "Stream" or "View Mappings"  (for Freestyle jobs).

          Customer would like to have the functionality to define a stream, and also have this stream checkout into a sub directory in the Jenkins workspace without having to fill in the "View Mappings" from a client spec by hand, with the directory present. 

          Karl Wirth added a comment - Comments from JENKINS-62123 :   In the P4Jenkins plugin, please add the functionality to "checkout to subdirectory" when defining either "Stream" or "View Mappings"  (for Freestyle jobs). Customer would like to have the functionality to define a stream, and also have this stream checkout into a sub directory in the Jenkins workspace without having to fill in the "View Mappings" from a client spec by hand, with the directory present. 

            Unassigned Unassigned
            tsackett Tom Sackett
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: