'Download a specific folder from on-prem GitLab

I have an on-prem GitLab with a huge repository with many folders.

I'm trying to create a freestyle Jenkins job that would only retrieve the folder from the repository. (I have a read-permitted API token)

With Jenkins or a bash script, is it possible to retrieve only a specific folder from an on-prem GitLab installation?

I've tried many things from online suggestions but nothing worked.

Thanks ahead!



Solution 1:[1]

I solved such kind of issue as follow:

   git clone --no-checkout --depth=1 <REPO_URI> repo.local \
&& cd repo.local \
&& git checkout <REPO_BRANCH> <REPO_FOLDER>/*

In other words:

  1. You clone only the latest repo layer.
  2. You checkout only the folder you need.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Antonio Petricca