1

My use case is that I would like to keep a list of submodules in .gitmodule. However, I will need each submodule separately while building my package. example let say below is the content of my .gitmodule file.

[submodule "submodule1"]     
   path = aiml/core/model/modelcollection   
   url = ssh://git@git.myorg.com/project/repo.git   
   branch = module1
[submodule "submodule2"]     
   path = aiml/core/model/modelcollection   
   url = ssh://git@git.myorg.com/project/repo.git   
   branch = module2

I am using the Jenkins checkout function as below.

checkout([
    $class: 'GitSCM',
    branches: [[name: 'develop']],
    doGenerateSubmoduleConfigurations: false,
    extensions: [[$class: 'SubmoduleOption',
        disableSubmodules: false,
        parentCredentials: true,
        recursiveSubmodules: true,
        reference: '',
        trackingSubmodules: false]
        ], 
    submoduleCfg: [], 
    userRemoteConfigs: [[url: "git@git.myorg.com/project/repo.git"]]
])

In the above Jenkins checkout function I could not find any option to restrict my submodule checkout to a specific submodule. ex:- I want to checkout only the submodule1 but not the submodule2.

Is there any way to achieve this? I am open to solutions either from the git side or from the Jenkins pipeline side. or Is there any better way to handle situations like this?

isherwood
  • 58,414
  • 16
  • 114
  • 157
SHC
  • 487
  • 1
  • 6
  • 19
  • Hi, @GeroldBroser thanks for the comment. the file name is ```.gitmodule``` only. I did not quite understand the checkout thing you spoke about. I have a main branch called ```develop``` and that should be cloned as the primary repo, then option to update a specific submodule is needed. – SHC Aug 06 '21 at 04:18
  • Would sparse checkout help? (https://stackoverflow.com/a/66030787/6309) – VonC Aug 06 '21 at 06:04

0 Answers0