Skip to main content

Clone Submodules

This tutorial explains how to clone submodules in build job

Clone via HTTP(s) Protocol

If submodules are defined to clone via HTTP(s) protocol:

  1. Create an access token with read code permission to main project and all submodule projects:

    create access token

  2. Edit build setting of the main project to define a job secret with value set to access token created above:

    add-access-token-secret

  3. Configure checkout step of the job to specify clone credential as HTTP(S), and select job secret created above as access token secret. Also make sure to tick the option Retrieve Submodules:

    Checkout With http

Clone via SSH Protocol

If submodules are defined to clone via SSH protocol:

  1. Make sure submodule repositories are referenced using same host as specified in SSH root url in system setting

  2. Make sure you can clone submodules locally in your terminal. To make it working, you will need to add public key (normally content of file ~/.ssh/id_rsa.pub) to your account and make sure your account has permission to pull submodule projects

    Add Ssh Key

  3. Edit build setting of the main project to define a job secret containing your private key (normally content of file ~/.ssh/id_rsa)

    Add Private Key

  4. Configure checkout step of the job to specify clone credential as SSH, and select job secret created above as key secret. Also make sure to tick the option Retrieve Submodules:

    Checkout With Ssh