Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden]

Basically, I am trying to deploy cloud functions using my cloudbuild.yaml file:

Cloudbuild.yaml

steps:
- name: 'node:10.10.0'
  id: installing_npm
  args: ['npm', 'install']
  dir: 'API/groups'
- name: 'gcr.io/cloud-builders/gcloud'
  id: deploy
  args: [
          'functions', 'deploy', 'groups', 
          '--region=us-central1',
          '--source=https://source.cloud.google.com/$PROJECT_ID/bitbucket_zebraema_/+/LCM-97_groups_API_test:API/groups', 
          '--trigger-http', 
          '--runtime=nodejs8', 
          '--entry-point=App', 
          '--allow-unauthenticated',
          '[email protected]'
        ]
  dir: 'API/groups'

Below is the error:

Step #0 - "installing_npm": npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Step #0 - "installing_npm": 
Step #0 - "installing_npm": added 448 packages from 284 contributors and audited 449 packages in 9.697s
Step #0 - "installing_npm": found 5 low severity vulnerabilities
Step #0 - "installing_npm":   run `npm audit fix` to fix them, or `npm audit` for details
Finished Step #0 - "installing_npm"
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[Permission 'cloudfunctions.functions.get' denied on resource 'projects/xxxxxxxxxxxxxxxx/locations/us-central1/functions/groups' (or resource may not exist).]
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

Edit: I have added Cloud functions Developer, Cloud functions Admin, Cloud Functions Service Agent and Service account user roles to my cloud build service account.

Cloudbuild.yaml

steps:
    - name: 'node:10.10.0'
      id: installing_npm
      args: ['npm', 'install']
      dir: 'API/groups'
    - name: 'gcr.io/cloud-builders/gcloud'
      id: deploy
      args: [
              'functions', 'deploy', 'groups', 
              '--region=us-central1',
              '--source=https://source.cloud.google.com/$PROJECT_ID/bitbucket_zebraema_/+/LCM-97_groups_API_test:API/groups', 
              '--trigger-http', 
              '--runtime=nodejs8', 
              '--entry-point=App', 
              '--allow-unauthenticated',
              '[email protected]'
            ]
      dir: 'API/groups'

Below logs:

Step #0 - "installing_npm":   run `npm audit fix` to fix them, or `npm audit` for details
Finished Step #0 - "installing_npm"
Starting Step #1 - "deploy"
Step #1 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "deploy": ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[The request has errors
Step #1 - "deploy": Problems:
Step #1 - "deploy": source_repository_url:
Step #1 - "deploy": Source repository URL is invalid https://source.cloud.google.com/xyxyxyxyx/bitbucket_zebraema/LCM-97_groups_API_test/API/groups/src does not match the expected pattern, which is https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/revisions/{REVISION_ID}/paths/{PATH} or https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/moveable-aliases/{BRANCH_ID}/paths/{PATH} or https://source.developers.google.com/projects/{PROJECT_ID}/repos/{REPOSITORY_ID}/fixed-aliases/{TAG_ID}/paths/{PATH}. Note that PROJECT_ID, REPOSITORY_ID, REVISION_ID, BRANCH_ID, and TAG_ID can not contain '/'. PATH may contain '/'.
Step #1 - "deploy": ]
Finished Step #1 - "deploy"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

Here, I have mirrored my bitbucket repository into my google cloud source repository. What is the correct way to write source_repository_url?

like image 204
Pritish Avatar asked Oct 28 '25 10:10

Pritish


1 Answers

Most likely reason is Cloud Functions Developer role not being enabled for the Cloud Build service.

  1. Navigate to Cloud Build > Settings
  2. Enable Cloud Functions Developer Role

enter image description here

like image 108
user1502505 Avatar answered Oct 30 '25 03:10

user1502505



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!