gcloud functions deploy: Deploy Cloud Functions in CI
Deploy a Cloud Function (Gen 1 or Gen 2) from source with a runtime and trigger.
gcloud functions deploy packages your source and deploys it as a Cloud Function. You specify the runtime, the entry point, and a trigger (HTTP or event). In CI you run it after tests pass to ship the new code.
Common flags
NAME- the function name (positional)--runtime=nodejs20- language runtime--trigger-httpor--trigger-topic=TOPIC- how the function is invoked--entry-point=fn- exported function to run--region=REGIONand--gen2- placement and generation
Example in CI
Deploy an HTTP-triggered Gen 2 function from the repo root.
shell
gcloud functions deploy api \
--gen2 --runtime=nodejs20 --region=us-central1 \
--trigger-http --entry-point=handler \
--source=. --quietCommon errors in CI
- Build failed: ... function not found - wrong --entry-point name
- OperationError: ... PERMISSION_DENIED - SA missing roles/cloudfunctions.developer
- Cloud Functions API has not been used ... before or it is disabled - enable cloudfunctions.googleapis.com
Key takeaways
- Deploys a function from source with an explicit runtime, entry point, and trigger.
- Use --gen2 for the modern Cloud Run-backed functions platform.
- Entry-point and IAM-role mismatches are the most common CI failures.
Related guides
gcloud run deploy: Ship to Cloud Run in CIDeploy a container or source to Cloud Run from a pipeline: the flags you need, a CI example, and the deploy e…
gcloud builds submit: Build with Cloud Build in CISubmit a build to Cloud Build from CI: key flags for tag and config, a pipeline example, and the build errors…
gcloud app deploy: Deploy App Engine in CIDeploy an App Engine service from a pipeline: version and promote flags, a CI example, and the deploy errors…