google-cloud-platform - 通过 GCP 控制台运行 Cloud Build 触发器返回 'build.service_account' 无法为触发build设置字段

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

我目前正在为我的 Dataflow Flex 模板使用 Cloud Build 来启 Action 业。 这是我当前的命令:

gcloud beta builds submit --config run.yaml --substitutions _REGION=$REGION \
--substitutions _FMPKEY=$FMPKEY --no-source

目前这在 Cloud Shell 中运行良好。 但现在我希望基于触发器启动构建。 因此,我创建了一个 Cloud Build,它将根据向主题发送消息来触发运行此文件:

https://github.com/mmistroni/GCP_Experiments/blob/master/dataflow/pipeline/run.yaml

但是,在向所选主题发布消息后,我的所有构建都失败并出现以下错误:

our build failed to run: generic::invalid_argument:generic::invalid_argument:
 'build.service_account' field cannot be set for triggered builds

我看不到任何日志或详细信息,所以我不清楚发生了什么...... 我猜这与我的 run.yaml 中的最后一行有关?

options:
  logging: CLOUD_LOGGING_ONLY

# Use the Compute Engine default service account to launch the job.
serviceAccount: projects/$PROJECT_ID/serviceAccounts/$PROJECT_NUMBER-compute@developer.gserviceaccount.com

但是我看不到在云构建中选择服务帐户的选项。我需要在 IAM 中设置一些权限吗?

最佳答案

您的猜测是正确的,这是按预期工作的。

Cloud Build 有一个默认服务帐户来代表您执行构建。虽然 GCP 允许您配置特定于用户的帐户以进行额外控制,但在您使用构建触发器时它并不适用。构建触发器仅使用默认服务帐户来执行构建。

这记录在 GCP docs 中:

Build triggers use Cloud Build service account to execute builds. This could provide elevated build-time permissions to users who use triggers to start a build. Keep the following security implications in mind when using build triggers ...

也是 limitation 的一部分:

User-specified service accounts only work with manual builds; they don't work with build triggers.

因此,如果您计划使用构建触发器,则必须传递不带 serviceAccount 的配置 yaml。

关于google-cloud-platform - 通过 GCP 控制台运行 Cloud Build 触发器返回 'build.service_account' 无法为触发build设置字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68351798/

相关文章:

google-cloud-platform - 创建触发器时如何在云构建中添加替换变量?

docker - 如何将参数传递给google cloud build中的docker run

node.js - Node Google Cloud KMS 加密似乎有效,但解密失败

firebase - 将 Google Firebase Firestore 与 ChatGPT API 集成

kubernetes - 默认情况下,节点到 Pod 的通信在 GCP 上不起作用

github - 云构建 "Google Cloud Platform was not authorised to list repositories"

google-cloud-build - 是否可以从由 GCB 步骤构建和启动的容器访问服务帐户凭据?

tensorflow - 通过 Google Cloud ML 部署 Keras 模型

java - Pubsub Java 订阅者在闲置一天后停止接收

google-cloud-build - 如何防止云构建并行运行构建?