Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCP cloudbuild optional step

Having this config on cloudbuild.yaml (there are other similar fragments on the file):

- name: 'gcr.io/cloud-builders/gcloud'
  id: 'step_1'
  args: ['builds',
         'submit',
         '--config=path_to_sub_app_1/app_1_build.yaml',
         '--substitutions=VAR_1=${ENV_VAR_1}']
  waitFor: ['Docker push']

- name: 'gcr.io/cloud-builders/gcloud'
  id: 'step_2'
  args: ['builds',
         'submit',
         '--config=path_to_sub_app_2/app_2_build.yaml',
         '--substitutions=VAR_1=${ENV_VAR_1}']
  waitFor: ['Docker push']

Is it possible to skip step_1 and continue the execution normally (step_2)?

like image 557
C.P.O Avatar asked Aug 27 '26 13:08

C.P.O


1 Answers

Use entrypoint: 'bash':

- name: 'gcr.io/cloud-builders/gcloud'
  id: 'step_1'
  entrypoint: 'bash'
  args:
    - '-c'
    - |
      if [ "$_SKIP_STEP" != "true" ]
      then
        gcloud builds submit --config=path_to_sub_app_1/app_1_build.yaml --substitutions=VAR_1=${ENV_VAR_1}
      fi
  waitFor: ['Docker push']

Define this var: _SKIP_STEP="false"

And now we can run the build and skip step_1:

gcloud builds submit --config=cloudbuild.yaml --substitutions=_SKIP_STEP=true
like image 140
C.P.O Avatar answered Aug 29 '26 15:08

C.P.O