Our project is huge and we would like to avoid cloning all git history.
Is it possible to git clone
passing depth=1
using checkout scm
in Jenkins?
I cannot find any documentation about how to configure SCM
or how to pass arguments, if possible.
Added:
Found the documentation
https://jenkins.io/doc/pipeline/steps/workflow-scm-step/#code-checkout-code-general-scm
Type: int
depth (optional)
Set shallow clone depth, so that git will only download recent history of the project, saving time and disk space when you just want to access the latest version of a repository.
but it's not clear how to pass it to checkout scm
If you use scripted pipeline then you can customize checkout scm
to look more or less like this:
node {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs,
depth: 1
])
}
If you use the declarative pipeline, then you need to go to your pipeline job configuration and in the Behaviors section you need to add Git -> Advanced clone behaviors and mark Shallow clone and set Shallow clone depth to 1
.