【问题标题】:GCP cloudbuild optional stepGCP cloudbuild 可选步骤
【发布时间】:2019-12-25 01:47:27
【问题描述】:

在 cloudbuild.yaml 上有这个配置(文件上还有其他类似的片段):

- 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']

是否可以跳过step_1继续正常执行(step_2)?

【问题讨论】:

    标签: google-cloud-platform google-cloud-build


    【解决方案1】:

    使用入口点:'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']
    

    定义这个变量:_SKIP_STEP="false"

    现在我们可以运行构建并跳过第 1 步:

    gcloud builds submit --config=cloudbuild.yaml --substitutions=_SKIP_STEP=true
    

    【讨论】:

      猜你喜欢
      • 2019-08-26
      • 1970-01-01
      • 2020-12-29
      • 2020-07-15
      • 2022-11-12
      • 2021-03-28
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      相关资源
      最近更新 更多