Search code examples
gitgit-submodulesgoogle-cloud-build

Cloud Build does not populate Git submodules


I have a Google Cloud Build trigger which I've set to a Github repo which has the option selected Cloud Build configuration file (yaml or json).

The repo has a submodule but I'm afraid the submodule is not populated by default. When I create a Compute VM from the resulting Docker image from the Cloud Build process, the logs show:

DEFAULT 2023-05-22T01 [resource.labels.instanceId: XXX-build] ImportError: cannot import name 'mysubmodule' from 'mysubmodule' (unknown location)  

I believe the issue is the submodules do not pull like when using git clone on a desktop. So I add the git submodule update --init command in the cloudbuild.yaml file below but the issue is the Cloud Build process doesn't understand the submodule command.

I've tried:

  • Changing the path to SSH gitpath: Cloud build failing on git submodules

  • Adding git command in cloudbuild.yaml:

    - name: "gcr.io/cloud-builders/git"
      args:
        - submodule update --init --recursive
    

    Result

    Step #0: git: 'submodule update --init --recursive' is not a git command. See 'git --help'.
    

There is also this bug: https://issuetracker.google.com/issues/123060361


Solution

  • As sub modules feature is not available yet you are facing the errors.And the issue tracker which you have mentioned is still open and further progress for this feature can be tracked there.You can raise your concern there and upvote the issue tracker.

    There is work around mentioned at same issue tracker which might help you.Additionally check out this github link that might help.