Skip to content
Latchkey

Cloud Functions "requires the Cloud Build API" in CI

Cloud Functions builds your source with Cloud Build. If the Cloud Build API (cloudbuild.googleapis.com) is not enabled on the project, the deploy cannot build the function and stops with a clear instruction to enable it.

What this error means

gcloud functions deploy fails with "Deploying functions requires the Cloud Build API to be enabled" or "API [cloudbuild.googleapis.com] not enabled on project". The same shape appears for artifactregistry or cloudfunctions APIs.

gcloud
ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden],
message=[Cloud Functions API has not been used in project 123456789 before or it is
disabled. Enable it by visiting https://console.developers.google.com/apis/api/
cloudfunctions.googleapis.com/overview?project=123456789]

Common causes

A required API is disabled on the project

New or minimally-configured projects do not have cloudbuild, cloudfunctions, or artifactregistry enabled, so the build step cannot run.

Deploying into a different project than expected

The active project lacks the enabled APIs even though another project has them, so the deploy fails on the wrong target.

How to fix it

Enable the required APIs

  1. Enable the Cloud Functions, Cloud Build, and Artifact Registry APIs on the project.
  2. Wait a moment for enablement to propagate.
  3. Re-run the deploy.
Terminal
gcloud services enable cloudfunctions.googleapis.com \
  cloudbuild.googleapis.com artifactregistry.googleapis.com

Confirm the active project

Ensure the deploy targets the project where the APIs are enabled.

Terminal
gcloud config get-value project

How to prevent it

  • Enable required APIs as part of project bootstrap, not in the deploy path.
  • Pin --project so deploys cannot drift to an unconfigured project.
  • Grant the CI account roles/serviceusage.serviceUsageConsumer to use enabled APIs.

Frequently asked questions

What causes ""requires the Cloud Build API""?
New or minimally-configured projects do not have cloudbuild, cloudfunctions, or artifactregistry enabled, so the build step cannot run.
How do I fix "requires the Cloud Build API"?
Enable the required APIs

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card