cloudbuild.yaml include a different cloud builder configuration
Asked Answered
S

1

10

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

Scrunch answered 11/8, 2018 at 20:10 Comment(0)
G
3

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.

Grantley answered 21/8, 2018 at 17:59 Comment(3)
What if you run gcloud command to build a different cloudbuild? Is there's a possibity to workaround that wayScrunch
If you are willing to do that, then it's possible that you can make it work. You can try running cloud build on one machine and then essentially use that machine (with all the required library and the cloudbuild.yaml) run cloud build and launch your real instance. I don't understand your use case though, why don't you simply have the cloudbuild.yaml in the root level for different folders? It's much less costly than doing it this way (having one instance launch another).Grantley
You may star this Feature Request on this topic for further updates, however there is no ETA or guarantee of implementation.Brisket

© 2022 - 2024 — McMap. All rights reserved.