Complete the code to enable lightweight checkout in a Jenkins pipeline.
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [[1]], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
The CloneOption with shallow: true enables lightweight checkout by cloning only the latest commit.
Complete the code to enable lightweight checkout in a Jenkins declarative pipeline.
pipeline {
agent any
options {
[1]
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
}
}The lightweightCheckout() option enables lightweight checkout in declarative pipelines.
Fix the error in the Jenkins pipeline snippet to correctly enable lightweight checkout.
pipeline {
agent any
options {
[1]
}
stages {
stage('Build') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
}
}
}
}Adding lightweightCheckout() in the options block enables lightweight checkout properly.
Fill both blanks to configure lightweight checkout with shallow clone and no tags in a scripted pipeline.
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[1], [2]], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
Using CloneOption with shallow: true enables shallow clone, and noTags: true avoids fetching tags, both helping lightweight checkout.
Fill all three blanks to create a Jenkins pipeline snippet that uses lightweight checkout with shallow clone, no tags, and disables submodule configurations.
checkout([$class: 'GitSCM', branches: [[name: '*/feature']], doGenerateSubmoduleConfigurations: [1], extensions: [[2], [3]], userRemoteConfigs: [[url: 'https://github.com/example/repo.git']]])
doGenerateSubmoduleConfigurations to true enables submodules, which is not lightweight.Setting doGenerateSubmoduleConfigurations to false disables submodule configs. Using CloneOption with shallow: true and noTags: true enables lightweight checkout.