首页 > 解决方案 > Gcloud 的功能从 shell 到 cloudbuild.yaml 不同

问题描述

我一直在尝试列出 gcloud 上的所有 API 网关配置,但发生了一些错误。

当我在用户登录的情况下在终端上运行以下命令时,它就像一个魅力。

gcloud api-gateway api-configs list --api=$API --project=$PROJECT_ID --format="table(name)"

但是当我从这个 cloudbuild.yaml 中运行相同的命令时

steps:
  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: "bash"
    args:
      - "-c"
      - |
        gcloud api-gateway api-configs list --api=logistics-homolog --project=$PROJECT_ID \
        --filter=serviceConfigId:logistics-mobile-places-* --format="table(name)"

它给了我以下错误:

ERROR: (gcloud.api-gateway.api-configs.list) PERMISSION_DENIED: Permission 'apigateway.apiconfigs.list' denied on 'projects/$PROJECT_ID/locations/global/apis/logistics-homolog/configs'

它出什么问题了?!

标签: google-cloud-platformgcloudgoogle-cloud-buildgoogle-cloud-api-gateway

解决方案


您没有包含足够的信息,但很可能您没有gcloud在容器中进行身份验证。

查看镜像的 repo 文档,了解如何对容器镜像进行身份验证;

https://github.com/GoogleCloudPlatform/cloud-sdk-docker


推荐阅读