Search code examples
dockergoogle-cloud-platformnestjsgoogle-cloud-buildgoogle-cloud-iam

GCP Cloud Build failed with error: Caller does not have permission or the resource may not exist


I am trying to deploy a nestjs application on a monorepo to GCD CI/CD "Cloud Build API". I pushed the images to Artifact Registry successfully.

My cloudbuild.yaml file looks like below:

steps:
  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'build',
        '-t',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/reservations/production',
        '-f',
        'apps/reservations/Dockerfile',
        '.',
      ]
  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'push',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/reservations/production',
      ]

  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'build',
        '-t',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/auth/production',
        '-f',
        'apps/auth/Dockerfile',
        '.',
      ]
  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'push',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/auth/production',
      ]

  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'build',
        '-t',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/notifications/production',
        '-f',
        'apps/notifications/Dockerfile',
        '.',
      ]
  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'push',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/notifications/production',
      ]

  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'build',
        '-t',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/payments/production',
        '-f',
        'apps/payments/Dockerfile',
        '.',
      ]
  - name: 'gcr.io/cloud-builder/docker'
    args:
      [
        'push',
        'europe-west1-docker.pkg.dev/driven-atrium-414021/payments/production',
      ]

I tried running $gcloud auth configure-docker gcr.io according to this source and I tried to play with permissions per other suggestions (new to GCP here) with no luck.

I got Caller does not have permission or the resource may not exist even though my user has the admin/owner role, I checked the repositories exists in the Artifact Repository. Here is a screenshot of my error from cloud build: enter image description here

Any help on how to solve this problem?


Solution

  • In your cloudbuild.yaml, change the names from gcr.io/cloud-builder/docker to gcr.io/cloud-builders/docker as stated in the documentation.