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

p4-plugin: Implement lightweight checkout of file from perforce repo

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin

      If we're using Pipeline Script from SCM with p4-plugin, in most cases we'll have two SCM checkouts performed: one for script, the other in "Declarative: Checkout SCM" stage. The first one could utilize lightweight checkout, so it checks out only Pipeline script thus making the build faster.

      Currently it's not supported:

      Lightweight checkout support not available, falling back to full checkout.

          [JENKINS-46269] p4-plugin: Implement lightweight checkout of file from perforce repo

          Mirek Sz created issue -
          Mirek Sz made changes -
          Description Original: If we're using Pipeline Script from SCM with p4-plugin, in most cases we'll have two SCM checkouts performed: one for script, the other in "Declarative: Checkout SCM" stage. The first one could utilize lightweight checkout, so it checks out only Pipeline script thus making the build faster. New: If we're using Pipeline Script from SCM with p4-plugin, in most cases we'll have two SCM checkouts performed: one for script, the other in "Declarative: Checkout SCM" stage. The first one could utilize lightweight checkout, so it checks out only Pipeline script thus making the build faster.

          Currently it's not supported:

          {{Lightweight checkout support not available, falling back to full checkout.}}

          Jeffrey Exterkate added a comment - - edited

          Also all commits are added to currentBuild.changeSets with the full checkout fallback, which ends up with all commits showing up twice in currentBuild.changeSets, for which there is no workaround in a sandboxed Jenkinsfile script. 

          Not doing the checkout step in the script will result in not getting the P4_CHANGELIST and other environment variables which the Jenkinsfile relies on.

          I did find a workaround by using:

          checkout changelog: false, scm:perforce( ... )

          Jeffrey Exterkate added a comment - - edited Also all commits are added to currentBuild.changeSets with the full checkout fallback, which ends up with all commits showing up twice in currentBuild.changeSets, for which there is no workaround in a sandboxed Jenkinsfile script.  Not doing the checkout step in the script will result in not getting the P4_CHANGELIST and other environment variables which the Jenkinsfile relies on. I did find a workaround by using: checkout changelog: false, scm:perforce( ... )
          Jeffrey Exterkate made changes -
          Priority Original: Major [ 3 ] New: Blocker [ 1 ]
          Jeffrey Exterkate made changes -
          Assignee New: Remik Pi [ p4 ]
          Jeffrey Exterkate made changes -
          Assignee Original: Remik Pi [ p4 ]
          Jeffrey Exterkate made changes -
          Assignee New: Paul Allen [ p4paul ]
          Jeffrey Exterkate made changes -
          Priority Original: Blocker [ 1 ] New: Major [ 3 ]

          Paul Allen added a comment -

          Lightweight checkout is on my TODO list, but after the next planned release (end of the month).

          Current workaround is to use the Workspace views (only map the Jenkinsfile in the -script workspace) and then use another workspace to map your code.

          see https://github.com/jenkinsci/p4-plugin/blob/master/WORKFLOW.md

          Paul Allen added a comment - Lightweight checkout is on my TODO list, but after the next planned release (end of the month). Current workaround is to use the Workspace views (only map the Jenkinsfile in the -script workspace) and then use another workspace to map your code. see https://github.com/jenkinsci/p4-plugin/blob/master/WORKFLOW.md

          I followed those instructions and have a separate workspace for syncing from within the Jenkinsfile. Now the Poll SCM will only pick up changes for executing the job when there is a change/commit to the Jenkinsfile. 

          I don't understand what "disable polling" does, but I can only specify that inside my Jenkinsfile, the Pipeline SCM UI doesn't have that option for perforce. Is that something that should help?

          Jeffrey Exterkate added a comment - I followed those instructions and have a separate workspace for syncing from within the Jenkinsfile. Now the Poll SCM will only pick up changes for executing the job when there is a change/commit to the Jenkinsfile.  I don't understand what "disable polling" does, but I can only specify that inside my Jenkinsfile, the Pipeline SCM UI doesn't have that option for perforce. Is that something that should help?

            p4paul Paul Allen
            mireksz Mirek Sz
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: