(GCP) ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com

(GCP) ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com

我正在尝试使用 Cloud [=53= 将 docker 图像上传到 GCR(Google Container Registry) ] 但我收到此错误消息:

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

这是我完成的步骤。

(第一步) 我 运行 这个命令:

gcloud builds submit --tag gcr.io/my_project_id/hello_world

(第 2 步) 然后,我被问到是否启用并重试 "API [cloudbuild.googleapis.com]" =38=] 然后,我输入 运行 "y":

Creating temporary tarball archive of 2 file(s) totalling 478 bytes before compression. Uploading tarball of [.] to [gs://my_project_id_cloudbuild/source/1642137449.192753-983fc894e2f24fa086f55fa3b56d58aa.tgz] API [cloudbuild.googleapis.com] not enabled on project [354778943856]. Would you like to enable and retry (this will take a few minutes)? (y/N)? y

(第 3 步) 最后,我收到了这条错误消息:

Enabling service [cloudbuild.googleapis.com] on project [354778943856]... Operation "operations/acf.p2-354778943856-e99f6fd8-78ec-4cbd-94a2-07e0697d5455" finished successfully. ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

尽管我通过 运行 "y"[=38 启用了 "API [cloudbuild.googleapis.com]" =], 我收到了错误信息。

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: could not resolve source: googleapi: Error 403: 354778943856@cloudbuild.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object., forbidden

有什么方法可以解决这个错误吗?

您在第二步的消息末尾找到下面的消息了吗?:

Would you like to enable and retry (this will take a few minutes)? (y/N)? y

如消息所述,启用 "API [cloudbuild.googleapis.com]" 后需要 几分钟 ] 通过 运行ning "y".

因此 运行 在启用 "API [cloudbuild.googleapis.com]" 几分钟后再次执行命令 运行ning "y":

gcloud builds submit --tag gcr.io/my_project_id/hello_world

那么,就成功了:

ID: f4478e51-557b-407d-9c30-c379ef707258 CREATE_TIME: 2022-01-14T05:22:29+00:00 DURATION: 19S SOURCE: gs://my_project_id_cloudbuild/source/1642137748.745566-d75b61b6c6bc4acb9aba900650f201b2.tgz IMAGES: gcr.io/my_project_id/hello_world(+1 more) STATUS: SUCCESS