Google Cloud Build sub builds

Viewed 848

Is possible have multiple cloudbuild.yaml files per subdirectory?

For example:

my-app:
  - service1
    - cloudbuild.yaml
  - service2
    - cloudbuild.yaml
  cloudbuild.yaml
2 Answers

The answer is almost correct. This will not work, because you forgot to include ".", which tells to upload and build the current directory. The correct way to include a sub/child cloudbuild.yaml would then be:

# Include cloudbuild sub step
- name: 'gcr.io/cloud-builders/gcloud'
  args:
  - 'builds'
  - 'submit'
  - '.'
  - '--config'
  - 'cloudbuild.yaml'

Yes, definitely! Are you trying to initialize the builds of service1 and service2 from my-app/cloudbuild.yaml?

Example of using a meta config to initialize other builds: https://github.com/GoogleCloudPlatform/cloudbuild-integration-testing/blob/master/cloudbuild.meta.yaml

Here is a cloudbuild.meta.yaml building off of your example:

steps:
- id: 'build service1'
  name: 'gcr.io/cloud-builders/gcloud'
  args: ['builds', 'submit', '--config service1/cloudbuild.yaml']
  waitFor: ['-'] #start in parallel
- id: 'build service2'
  name: 'gcr.io/cloud-builders/gcloud'
  args: ['builds', 'submit', '--config service2/cloudbuild.yaml']
  waitFor: ['-'] # start in parallel
Related