You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cloud Build部署GCP Gen2 Cloud Function失败求助

Cloud Build部署Gen2 Cloud Function触发器失败的解决办法

问题核心:Cloud Build YAML的args数组中,给--trigger-event-filters等参数添加了双引号,导致gcloud命令无法正确识别触发器事件类型。本地终端执行时,shell会自动解析并去掉引号,但Cloud Build会把引号当作参数的一部分传递给gcloud,使得GCP无法识别带引号的事件类型值,因此抛出Trigger event type must be specified.错误。

修正后的cloudbuild.yaml代码片段:

- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
args:
  - gcloud
  - functions
  - deploy
  - function_name
  - --gen2
  - --entry-point=main
  - --runtime=python39
  - --region=${_CF_REGION}
  - --source=./sample/dir
  - --trigger-event-filters=type=google.cloud.firestore.document.v1.written
  - --trigger-event-filters=database=(default)
  - --trigger-event-filters-path-pattern=document=Sample/{docId}
  - --trigger-location=${_TRIGGER_REGION}
  - --trigger-service-account=${_TRIGGER_SERVICE_ACCOUNT}

说明:Cloud Build的args数组每个元素会直接作为命令参数传递,无需额外给参数值添加引号。只有当参数包含空格、特殊字符时,才需要在YAML中用引号包裹整个参数元素(而非给参数值加引号),而你的这些参数值没有特殊字符,去掉引号即可让gcloud正确解析触发器配置。

内容的提问来源于stack exchange,提问作者Mursil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 20:32:43