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

Option to create ref-spec to target branch when cloning

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins 2.204.2
      Git Plugin 4.1.1

      We use the Kubernetes plugin to run Jenkins which means that every stage in our pipelines will always perform a full clone. Unfortunately this mean that the current behavior is to fetch all the branches which uses a lot more bandwidth and RAM than we need.

      We can can manually set the ref-spec to the target branch if the job will only run against a specific branch, but we have many pipelines that are allowed to run against any branch, in which case the ref-spec need to be left to default. We've had many pipeline failures caused by the git process running out of memory, or by the git server timing out.

      To work around these issue we have a shell script that wraps the git cli to:

      • retry the commands 5 times, with backoff logic so stages won't fail due to a network/server glitch while fetching.
      • detect if $BRANCH is set (GIT_BRANCH is not exposed here) and if the wildcard ref-spec is set massage the git fetch command to only fetch the targeted branch.

      This approach has lowered out git checkout times by 3x, the number of objects by 10x and the amount of data fetched from the git server by over 10x.

      It would be great to add theses 2 improvements directly into the git plugin so that others can benefit from this. We do know about the option to use a reference repo but in our case it would be stored on EFS and that would also benefit from these improvements.

            Unassigned Unassigned
            sodul Stephane Odul
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: