What does `skipDefaultCheckout` do, and when do you need it?
IntermediateConceptDeclarative pipeline syntax
Answer
By default a declarative pipeline from SCM checks out the repo automatically when an agent is allocated (at pipeline level and in each stage with its own agent). options { skipDefaultCheckout() } disables that. Use it when stages do not need the source (deploy pods, notification stages), when you need custom checkout options (shallow clone, sparse checkout, submodules), or to avoid repeated clones of a large repo.
checkout scmGit(branches: [[name: env.BRANCH_NAME]], extensions: [cloneOption(shallow: true, depth: 1, noTags: true)], userRemoteConfigs: scm.userRemoteConfigs)
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate