ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not parse service account URL

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not parse service account URL

我想使用自定义服务帐户通过 Cloud Build 构建我的 docker 容器。使用 gcloud iam service-accounts listgcloud config list 我已确认服务帐户在项目环境中,我使用 gcloud services list --enabled 检查 cloudbuild.googleapis.com 是否已启用。我收到错误:ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not parse service account URL。我尝试了所有可用的服务帐户,并尝试使用和不使用前缀路径。使服务帐户正常工作的正确 URL 或配置是什么?

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/my-project-id/my-app']
images: ['gcr.io/my-project-id/my-app']
serviceAccount: 'projects/my-project-id/serviceAccount/my-sa@my-project-id.iam.gserviceaccount.com'
options:
  logging: CLOUD_LOGGING_ONLY

serviceAccount references this 页面的构建配置以及显示结构的示例:

projects/{project-id}/serviceAccounts/{service-account-email}

因此,它遵循 Google 的 API 复数名词约定(即 serviceAccounts),后跟唯一标识符。

另一种确认方式是通过 APIs Explorer for Cloud Build

该服务的 Build resource defines serviceAccount 也是。