I am using Jenkins file to build a pipeline. I am trying to clone the reference repository using DSL like below.
checkout(
[$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true]],
submoduleCfg: [],
userRemoteConfigs: [[url: '[email protected]:user_team/infrastructure-as-code.git']])
and while the pipeline is being executed, it is being translated to this
git fetch --tags --progress [email protected]:userteam/infrastructure-as-code.git +refs/heads/*:refs/remotes/origin/* --depth=1
This clones the whole repository on my Jenkins server. I just want to obtain a shallow copy of my repo so that I could save my Jenkins server from space crunch. Please help here.
I am using: Jenkins version: 2.58,
Plugins:
Pipeline SCM Step: 2.4
Git: 3.3.0
I think you are misunderstanding the meaning of shallow clone.
Shallow clone will still clone the entire repository.
The difference will be that history will be truncated to the specified number of commits (in your case 1, since you have mentioned depth to be one.) It can save you a lot of space and time.
For more information please follow this link: git-clone#Documentation
For instance, see the below image where I am cloning same repository ( https://github.com/spring-cloud/spring-cloud-config.git) 2 times, one without depth and one with depth=1. In first case, the local repository size is 40 MB and with depth the local repository size is mere 3.4 MB.