Google Cloud Build Basics
Prerequisites
Before starting, ensure the following prerequisites are met:
- Google Cloud SDK: Ensure the Google Cloud SDK is installed and configured.
- Authentication: Authenticate the gcloud CLI:
```bash
gcloud auth login
gcloud auth application-default login
```
- Project ID: Know the target Google Cloud Project ID. Set the context:
```bash
gcloud config set project <PROJECT_ID>
```
- Enable Cloud Build API: The Cloud Build API must be enabled for the project.
```bash
gcloud services enable cloudbuild.googleapis.com
```
- Permissions: Ensure the user or service account has the necessary permissions, such as
roles/cloudbuild.builds.editorandroles/serviceusage.serviceUsageAdmin(to enable the API).
Core Concepts
Google Cloud Build (GCB) is a serverless platform that executes your builds on Google Cloud. It translates your source code into deployable artifacts, such as Docker containers or Java archives.
| Concept | Description |
| :--- | :--- |
| cloudbuild.yaml | The required configuration file that defines the build steps. It is written in YAML or JSON. |
| Build Steps | A sequence of actions (steps) GCB performs. Each step runs a command inside a specific Docker container (the builder). Common builders include gcr.io/cloud-builders/gcloud, gcr.io/cloud-builders/docker, and custom containers. |
| Artifacts | The output of the build, typically a container image pushed to Google Container Registry (GCR) or Artifact Registry (AR), or other deployable files. |
| Triggers | Automation rules that invoke a build in response to an event, such as a push to a Git repository, a Pub/Sub message, or a manual request. |
Navigation: Viewing Build History
The Cloud Build Build History page is the central place to monitor the status of past and ongoing builds.
- Open the Cloud Console: Navigate to the Google Cloud Console.
- Go to Cloud Build: Use the search bar or the navigation menu to find Cloud Build.
- Select Build History: In the left navigation pane, select History (or use the direct URL:
https://console.cloud.google.com/cloud-build/builds). - Review Builds:
- Status: Check the status column (
SUCCESS,FAILURE,WORKING,QUEUED). - Region: Use the region filter at the top to view builds that ran in a specific region (important for regional worker pools).
- Logs: Click on a specific Build ID to view the detailed logs, execution steps, and build summary. This is crucial for debugging failed builds.
[!NOTE]
If this is your first time visiting the page, you might see the "zero-state" experience, which offers options to run a sample build or create your first trigger (as noted in the