运行 Cloud Build 通过 GCP Console 触发 returns 'build.service_account' 无法为触发的构建设置字段
Running Cloud Build trigger via GCP Console returns 'build.service_account' field cannot be set for triggered builds
我目前正在为我的 Dataflow Flex 模板使用 Cloud Build 来启动作业。
这是我当前的命令:
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。
我目前正在为我的 Dataflow Flex 模板使用 Cloud Build 来启动作业。 这是我当前的命令:
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。