Search code examples
google-cloud-build

Google Cloud Build - Cant Update Submodules


I configured google cloud build (GCB) to trigger a build on one of my repositories in Github. This repository requires another git repository in order to be built. This other repository is configured using a git submodule.

I search and at the moment it looks like GCB do not support submodules. So I am trying to run git submodule update --init manually on the source code that GCB downloaded, but there is not .gitdirectory on it and the command fails.

What am I missing here?

I am using this issue as reference: https://github.com/GoogleCloudPlatform/cloud-builders/issues/435


Solution

  • If trigger your build using github it will not work because of the lack of the .git folder. In order for it to work, all repositories need to be mirrored by Cloud Source Repositories. Then, the submodule can be updated like this:

    - name: 'gcr.io/cloud-builders/git'
      entrypoint: 'bash'
      args:
      - '-c'
      - |
        git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
        git submodule init
        git submodule update
    
    

    Ref: https://github.com/GoogleCloudPlatform/cloud-builders/issues/26