{"id":985,"library":"google-cloud-build","title":"Google Cloud Build","description":"The `google-cloud-build` client library provides Python APIs to interact with Google Cloud Build, a service that executes your builds on Google Cloud Platform infrastructure. It allows users to define custom workflows for building, testing, and deploying across various environments. The library is currently at version 3.35.0 and is part of the Google Cloud Python client libraries, which receive frequent updates across their various service clients, often on a weekly or bi-weekly basis for individual clients.","status":"active","version":"3.35.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-build","tags":["google cloud","gcp","build","ci/cd","devops","cloud build"],"install":[{"cmd":"pip install google-cloud-build","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core library for Google API clients, providing common functionality like authentication, retries, and error handling.","package":"google-api-core"},{"reason":"Handles authentication with Google Cloud, including Application Default Credentials.","package":"google-auth"},{"reason":"Used for serialization and deserialization of API messages.","package":"google-protobuf"}],"imports":[{"wrong":"from google.cloud import build_v1","symbol":"CloudBuildClient","correct":"from google.cloud.devtools.cloudbuild_v1 import CloudBuildClient"}],"quickstart":{"code":"import os\nfrom google.cloud import build_v1\nfrom google.api_core.exceptions import GoogleAPIError\n\nproject_id = os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-gcp-project-id')\n\ntry:\n    # Initialize the Cloud Build client\n    client = build_v1.CloudBuildClient()\n\n    # List recent builds for the specified project\n    print(f\"Listing recent builds for project: {project_id}\")\n    request = build_v1.ListBuildsRequest(project_id=project_id)\n    builds = client.list_builds(request=request)\n\n    if not builds.builds:\n        print(\"No builds found.\")\n    else:\n        for build in builds.builds:\n            print(f\"  Build ID: {build.id}, Status: {build.status.name}, Create Time: {build.create_time.isoformat()}\")\n\nexcept GoogleAPIError as e:\n    print(f\"An API error occurred: {e}\")\n    print(\"Please ensure the Cloud Build API is enabled and your credentials have sufficient permissions.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart initializes the Cloud Build client and lists recent builds for a specified Google Cloud project. Ensure the `GOOGLE_CLOUD_PROJECT` environment variable is set or replace 'your-gcp-project-id' with your project ID. The Cloud Build API must be enabled, and your credentials must have the `cloudbuild.builds.list` permission."},"warnings":[{"fix":"Use `gcloud auth application-default login` for local setup. For GCP deployments (e.g., Cloud Run, GKE, Cloud Functions), ensure your service account has the necessary IAM roles (e.g., Cloud Build Editor or custom roles) and rely on ADC to automatically pick up credentials.","message":"Application Default Credentials (ADC) is the recommended authentication method. Avoid hardcoding service account key files in your code, especially in production environments. Use `gcloud auth application-default login` for local development or rely on attached service accounts for GCP deployments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the Cloud Build release notes and official documentation regarding service account changes. Ensure your Cloud Build service account has appropriate permissions and is configured for impersonation if deploying to managed services. For new projects, verify the default service account behavior.","message":"Cloud Build has undergone changes to how it uses service accounts for new projects and the handling of the 'Service Account User' role. This might impact permission configurations, requiring explicit configuration for service account impersonation for managed services.","severity":"breaking","affected_versions":"Introduced October 09, 2025 (role removal), July 02, 2024 (new project policy constraints)"},{"fix":"For build steps that are expected to take longer, explicitly set the `timeout` field in your `cloudbuild.yaml` for that specific step or for the entire build.","message":"Build steps in Cloud Build have a default timeout of 10 minutes. Long-running operations may fail with a 'Step exceeded maximum allowed runtime' error if this limit is reached.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Exercise caution when saving or exposing logs. Do not depend on the immutability of logging events for programmatic parsing. Configure log handling explicitly if you need to capture and process logs.","message":"The logging events from `google-cloud-build` (and other Google Cloud Python client libraries) may contain sensitive information, and their occurrence, level, and content can change without being flagged as a breaking change.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the `google-cloud-build` library is installed (`pip install google-cloud-build`) and use the correct import statement: `from google.cloud import cloudbuild_v1`.","message":"The standard import for the `google-cloud-build` library is `from google.cloud import cloudbuild_v1`. Attempting to import `build_v1` directly from `google.cloud` will result in an `ImportError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the `google-cloud-build` library is properly installed in your Python environment (e.g., `pip install google-cloud-build`). Check your project's dependencies (like `requirements.txt`) and your build script or Dockerfile to confirm the package is being installed before execution.","message":"An `ImportError` occurs when trying to import `build_v1` from `google.cloud`. This indicates that the `google-cloud-build` package, which provides the Cloud Build API client, is likely not installed in the Python environment, or there's an issue with its installation.","severity":"gotcha","affected_versions":"All versions (when `google-cloud-build` is not installed)"}],"env_vars":null,"search_vec":"'3.35.0':52 'across':43,67 'allow':32 'api':13 'basi':80 'bi':78 'bi-week':77 'build':3,8,19,25,39,87,91 'ci/cd':88 'client':9,61,71,83 'cloud':2,7,18,28,59,85,90 'current':49 'custom':36 'defin':35 'deploy':42 'devop':89 'environ':45 'execut':23 'frequent':65 'gcp':86 'googl':1,6,17,27,58,84 'google-cloud-build':5 'individu':82 'infrastructur':30 'interact':15 'librari':10,47,62 'often':72 'part':55 'platform':29 'provid':11 'python':12,60 'receiv':64 'servic':21,70 'test':40 'updat':66 'user':33 'various':44,69 'version':51 'week':75,79 'workflow':37","created_at":"2026-03-29T08:37:35.107017+00:00","updated_at":"2026-04-16T15:20:29.543154+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":0,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.37.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://cloud.google.com/build","github":"https://github.com/googleapis/google-cloud-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/google-cloud-build/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":"stale"}}