so normally if your Jenkinsfile is coming from your gerrit change review or gitlab/hub PR, you can leave the defaults as they are and simply use this in your pipeline's git checkout step:
checkout scm
If you instead store your pipeline jobs in one place (say, in another repo, or maybe on their own branch for some reason), then you might end up with a case where you need to perform a more complex git clone operation within your pipeline:
we're specifying that even though Jenkins might be executing the pipeline as it's defined in the origin/master branch, we still want to checkout the code from the gerrit change review
extension configuration for shallow clone requires an inline CloneOption class reference
So...this works....but I'm not sure how to make this better...yet.
so normally if your
Jenkinsfile
is coming from your gerrit change review or gitlab/hub PR, you can leave the defaults as they are and simply use this in your pipeline's git checkout step:If you instead store your pipeline jobs in one place (say, in another repo, or maybe on their own branch for some reason), then you might end up with a case where you need to perform a more complex git clone operation within your pipeline:
This is some tricky syntax:
CloneOption
class referenceSo...this works....but I'm not sure how to make this better...yet.
source: https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch