Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shallow git submodule checkout using Jenkins

I have no problem doing this using git commands, as in Set Git submodule to shallow clone & sparse checkout? but I have a project using Jenkins and I'm using the checkout() function in the Groovy Pipeline syntax. I can't find any option to pass the --depth option to the git submodule update commands.

like image 353
kph Avatar asked Feb 16 '26 05:02

kph


1 Answers

You should be able to use the extensions parameter in the checkout step:

checkout([
  $class: 'GitSCM', 
  branches: [[name: 'master']], 
  doGenerateSubmoduleConfigurations: false, 
  extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]],
  submoduleCfg: [], 
  userRemoteConfigs: [[url: '[email protected]:repo/repo.git']]])

If you are using the snippet generator, select Additional Behaviors -> Advanced clone behaviors to see the different options. Hope that helps!

like image 89
Becca Gaspard Avatar answered Feb 19 '26 13:02

Becca Gaspard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!