4

When our GitLab CI/CD job runs, it first pulls a Docker image and then git clones the entire repo. Afterwards, the Build commands are executed in the Docker image, etc.

Is it possible to only clone the non-LFS files from the repo? ... Or perhaps clone the HEAD of the master branch from only a specific subdirectory and it's subdirectories, etc.?

rickhg12hs
  • 191
  • 1
  • 6

1 Answers1

5

Yes, full cloning of LFS files can be restricted! By default, GitLab will clone your repo into the CI/CD build directory. To limit the clone from downloading the LFS files, tell it not to do it. You do this by setting a variable in .gitlab-ci.yml like this.

# Other declarations etc above the specific job
jobname:
  variables:
    GIT_LFS_SKIP_SMUDGE: 1
# More job declarations, etc.

The "smudge" process replaces the link/pointers to the LFS files with the actual files. By telling GitLab's CI job to skip the smudge, the LFS files aren't downloaded.

Placing GIT_LFS_SKIP_SMUDGE: 1 in a variables section at the top may make it apply to all of the defined jobs.

rickhg12hs
  • 191
  • 1
  • 6