10
votes

My project is split into gitmodules like so:

/ +
  |
  +-module_1
  |  |
  |  +- cloudbuild.yaml 
  |  +- src/
  |  +-.git/
  | 
  +-module_2
  |  |
  |  +- cloudbuild.yaml 
  |  +- src/
  |  +-.git/
  | 
  +- .git/
  +- .gitmodules
  +- cloudbuild.yaml

I'm trying to build submodules from parent repository, but cloudbuild has a problem with that, as it does not fetch gitmodules by itsself. So when I reference module_1/cloudbuild.yaml as a cloudbuild configuration the build fails because this file does not exist. I'm thinking about possilbe workarounds and i'd like to ask if the following is possible:

  1. referencing /cloudbuild.yaml as a build config
  2. adding a step to fetch gitmodules in cloudbuild.yaml
  3. Run a different cloudbuild file

The result should look something like:

steps:
  - name: 'gcr.io/$PROJECT_ID/git'
    args: ['submodule', 'update', '--init']
  - name: 'some kind of command that runs cloudbuild.yaml`
    args: ['module_1/cloudbuild.yaml']

Disclaimer I'm aware that I can just place all the cloudbuild configs inside the root repository, but I'd like the modules to be as much self-governing as possible

1

1 Answers

3
votes

I don't think what you want is possible. I don't think this part can work: - name: 'some kind of command that runs cloudbuild.yaml'

The best thing might be simply filing a feature request with our issue tracker that will allow you to reference "module_1/cloudbuild.yaml" directly as a configuration.