6

我正在尝试通过云构建触发器将 html 代码从一个云源存储库发布到 gcp 中的公共存储桶。但是,每次推送到主分支时,都会在构建中收到以下错误。

generic::invalid_argument: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket' (b) use the CLOUD_LOGGING_ONLY logging option, or (c) use the NONE logging option

我正在使用以下 cloudbuild.yaml

steps:
  - name: gcr.io/cloud-builders/gsutil
    args: ["-m", "rsync", "-r", "-c", "-d", ".", "gs://somedomain.com"]

我认为这与与云构建关联的服务帐户有关。

我正在关注此解决方案的教程在这里:https ://cloud.google.com/community/tutorials/automated-publishing-cloud-build

4

3 回答 3

7

在 cloudbuild.yaml 末尾添加日志规范并启用 IAM API 解决了该错误。存储桶和云构建配置在同一个项目中,因此我不需要向云构建服务帐户授予其他角色。

 options:
 logging: CLOUD_LOGGING_ONLY
于 2021-08-20T07:37:17.583 回答
2

似乎 Cloud Build 是从一个特定的服务帐户开始的,并且该帐户无权在 Logging 中存储构建日志。

将 Logging Admin (roles/logging.admin) 角色授予您在 YAML 文件中指定的服务帐户。

本文档包含有关配置用户指定的服务帐户的更多信息

于 2021-08-14T21:02:11.170 回答
0

Cloud Build文档涵盖了所有可用的日志记录选项。

而(同时)正确的角色是roles/storage.admin.

于 2021-08-24T23:53:13.637 回答