ruebenramirez / blog

My blog
http://blog.ruebenramirez.com/
7 stars 0 forks source link

jenkins explicity specifying shallow git clone commands #396

Open ruebenramirez opened 7 years ago

ruebenramirez commented 7 years ago

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:

checkout([$class: 'GitSCM', branches: [[name: "FETCH_HEAD"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', noTags: true, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'some_ssh_private_key_secret', name: "", refspec: "${GERRIT_REFSPEC}", url: 'ssh://USER@gerrit_server.com:29418/REPO/NAME']]])

This is some tricky syntax:

So...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