求助修正Cloud Build部署Cloud Function的cloudbuild.yaml参数错误
Looks like you ran into a classic mix-up between your intended bucket name and what you actually wrote in the config—plus a tiny parameter formatting check. Let's break this down and fix your cloudbuild.yaml right away.
The Core Issue
Your error messages reference hjemmeside as the bucket name, but you explicitly stated your trigger bucket is named homepage. That misspelling is the primary culprit here—GCP can't recognize a bucket that doesn't match what exists in your project, so it throws that confusing "unrecognized arguments" error.
Corrected Configuration Options
Option 1: Simplified Trigger with --trigger-bucket
This is the quickest way to bind your function to bucket uploads (it defaults to the google.storage.object.finalize event):
steps: - name: 'gcr.io/cloud-builders/gcloud' args: - functions - deploy - pupetter-e2e - --source=. - --trigger-bucket=homepage
Alternatively, you can split the parameter and value into separate args elements (both formats work):
steps: - name: 'gcr.io/cloud-builders/gcloud' args: - functions - deploy - pupetter-e2e - --source=. - --trigger-bucket - homepage
Option 2: Explicit Event Trigger with --trigger-resource & --trigger-event
If you need to specify a different storage event (like object deletion or metadata updates), use this full configuration—just make sure the bucket name is correct:
steps: - name: 'gcr.io/cloud-builders/gcloud' args: - functions - deploy - pupetter-e2e - --source=. - --trigger-resource=homepage - --trigger-event=google.storage.object.finalize
You can replace google.storage.object.finalize with other valid storage events (e.g., google.storage.object.delete, google.storage.object.metadataUpdate) based on your needs.
Quick Pre-Deployment Checks
- Verify the bucket
homepageexists in your GCP project (rungsutil lsto list buckets). - Ensure your Cloud Build service account has the necessary permissions: at minimum,
roles/cloudfunctions.developerandroles/storage.admin(or more granular permissions if you prefer). - Test the command locally first to rule out other issues:
gcloud functions deploy pupetter-e2e --source=. --trigger-bucket homepage
If this local command works, your Cloud Build config will too.
内容的提问来源于stack exchange,提问作者stian

