How do I get Google Cloud Build to properly substitute values when it responds to a GitHub trigger?

空扰寡人 提交于 2020-01-14 08:29:11

问题


The Problem

A GitHub trigger set up in Google Cloud Build doesn't actually substitute the configured values while running the Build (cloudbuild.yaml)

This is the Google Cloud Build config

cloudbuild.yaml

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  id: 'decrypt .npmrc'
  args:
  - kms
  - decrypt
  - --ciphertext-file=npmrc.enc
  - --plaintext-file=/root/.npmrc
  - --location=global
  - --keyring=my-keyring
  - --key=npm-key
  - --project=${_CLOUD_KMS_PROJECT}
  volumes:
    - name: 'home'
      path: /root/
- name: 'gcr.io/cloud-builders/npm'
  id: 'install'
  args: ['install']
  env:
  - HOME=/root/
  volumes:
  - name: 'home'
    path: /root/
- name: 'gcr.io/cloud-builders/npm'
  id: 'test'
  args: ['run', 'test']
- name: gcr.io/$PROJECT_ID/skaffold:alpha
  id: 'deploy'
  args: ['run', '-f=${_SKAFFOLD_FILE}']
  env:
  - CLOUDSDK_COMPUTE_ZONE=${_CLOUDSDK_COMPUTE_ZONE}
  - CLOUDSDK_CONTAINER_CLUSTER=${_CLOUDSDK_CONTAINER_CLUSTER}
substitutions:
    _SKAFFOLD_FILE: dummy.yaml
    _CLOUDSDK_COMPUTE_ZONE: us-west1-a
    _CLOUDSDK_CONTAINER_CLUSTER: dummy
timeout: 1000s

Curiously, when triggering the build via a gcloud SDK call it works ✅ ex:

gcloud builds submit --config=cloudbuild.yaml --substitutions=_SKAFFOLD_FILE=skaffold.yaml,_CLOUDSDK_COMPUTE_ZONE=us-west1-a,_CLOUDSDK_CONTAINER_CLUSTER=skaffold .

Some more context

Cloud Build Trigger dashboard (img)

Trigger configuration with substitutions (img)

Missing substitutions in Build history from triggered build (img)

In contrast: Correctly substituted values when running gcloud builds submit (img)

来源:https://stackoverflow.com/questions/52423477/how-do-i-get-google-cloud-build-to-properly-substitute-values-when-it-responds-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!