Please help with a real working example with "checkout"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Please help with a real working example with "checkout"

unlimhost
Please help with a real working example with "checkout sparse".

My code that doesn't work correctly. I expect when running this code that only the "/src/jenkins" folder from my SCM will be cloned locally, but this still clones the entire repository (4GB).
I only need the /src/jenkins folder from my github-repository to execute pipeline.

My checkout code:

checkout ([
    $class: 'GitSCM',
    branches: [[name: '"*/"${params.branch_name}']],
    doGenerateSubmoduleConfigurations: 'false',
    extensions: [[$class: 'SparseCheckoutPaths', path: '/src/jenkins'],[$class: 'CheckoutOption', timeout: 180],[$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: false, timeout: 60]],
    submoduleCfg: [],
    userRemoteConfigs: [[url: 'https://github.com/myrepo.git', credentialsId: 'github-pat']]])

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/929505518.20201112151626%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Please help with a real working example with "checkout"

Mark Waite-2
Git's 'sparse checkout' doesn't limit the amount of data copied from the remote git server.  The "clone" and `fetch` operations are distinct from the "checkout" operation.  If you want to reduce the amount of data transferred from the central git repository to the Jenkins agent, you need to change options on the clone or fetch, not on the checkout.

Options to consider changing include:
  • Narrow the refspec to only fetch a subset of the total branches in the repository (if many branches are in the repository with distinct content in each branch, this can help very much)
  • Place a reference repository on the agent and use it from the job so that the content is referenced rather than copied from the remote server (if the repository includes large binary files, this can help very much)
  • Reduce the clone depth to only fetch a subset of the history (this has not been as beneficial in my experience unless the earlier two techniques are also used, but it certainly can help)
The git sparse checkout limits the directories that will be extracted from the fetched content and placed into the directories in the workspace.  It can help reduce workspace disc use but won't reduce the amount of data transferred from the remote repository.

If you prefer a talk that describes the alternatives, see https://youtu.be/jBGFjFc6Jf8?t=6434

Mark Waite

On Thu, Nov 12, 2020 at 11:20 AM <[hidden email]> wrote:
Please help with a real working example with "checkout sparse".

My code that doesn't work correctly. I expect when running this code that only the "/src/jenkins" folder from my SCM will be cloned locally, but this still clones the entire repository (4GB).
I only need the /src/jenkins folder from my github-repository to execute pipeline.

My checkout code:

checkout ([
    $class: 'GitSCM',
    branches: [[name: '"*/"${params.branch_name}']],
    doGenerateSubmoduleConfigurations: 'false',
    extensions: [[$class: 'SparseCheckoutPaths', path: '/src/jenkins'],[$class: 'CheckoutOption', timeout: 180],[$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: false, timeout: 60]],
    submoduleCfg: [],
    userRemoteConfigs: [[url: 'https://github.com/myrepo.git', credentialsId: 'github-pat']]])

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/929505518.20201112151626%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEXKM4%2Bj0CB%3D_DWvXfKdTHBxaPqbbV9eF2JNxNytriVMg%40mail.gmail.com.