Generated banner for Cloud Build Basics
Generated logo for Cloud Build Basics

Cloud Build Basics

GoogleOfficialPublished by Google

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • No issues found

From the author

Teaches the fundamentals of Cloud Build on Google Cloud. Covers core concepts, API enablement, console navigation to the Build History page, and the end-to-end workflow for creating and manually running a basic build trigger. Do not use for managing private pools or complex pipeline architectures.
— the description by Google

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Cloud Build Basics provides a foundational guide to using Google Cloud's serverless CI/CD platform. It covers the essential concepts of build configurations, triggers, and artifacts. The skill walks users through the necessary prerequisites, such as API enablement and authentication, and provides step-by-step instructions for creating automated build triggers and manually executing builds via both the Google Cloud Console and the gcloud CLI.

What it does

  • Explains core Cloud Build concepts like cloudbuild.yaml, build steps, and triggers.
  • Guides users through enabling the Cloud Build API and configuring project authentication.
  • Provides instructions for navigating the Build History page to monitor build status and logs.
  • Details the workflow for creating automated triggers based on repository events.
  • Demonstrates how to manually run existing triggers using the console or command line.
  • Includes guidance on overriding substitution variables during manual trigger execution.

When to use it

  • When you are new to Google Cloud Build and need to understand its basic workflow.
  • When you need to set up a simple automated build trigger for a repository.
  • When you need to manually trigger a build or debug a failed build via logs.
  • When you require a quick reference for basic gcloud commands related to Cloud Build.

Advantages

  • Provides a clear, structured path for beginners to get started with Cloud Build.
  • Covers both GUI-based and CLI-based workflows for flexibility.
  • Includes essential troubleshooting tips like accessing build logs.
  • Emphasizes best practices like using service accounts for production environments.

Usage examples

“How do I enable the Cloud Build API for my project?”
The agent will provide the gcloud command to enable the cloudbuild.googleapis.com service and verify project context.
“Show me how to manually run a build trigger named my-trigger in the global region.”
The agent will provide the gcloud builds triggers run command with the appropriate flags for the trigger name and region.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/google/cloud-build-basics/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip cloud-build-basics.zip -d .agents/skills

Documentation by Google

Cloud Build Basics

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-build-basics)" and append agent-skills/1.0 (skill:cloud-build-basics) to User-Agent headers.

Prerequisites

Before starting, ensure the following prerequisites are met:

  1. Google Cloud SDK: Ensure the Google Cloud SDK is installed and configured.

  2. Authentication: Authenticate the gcloud CLI:

    gcloud auth login
    gcloud auth application-default login
  3. Project ID: Know the target Google Cloud Project ID. Set the context:

    gcloud config set project <PROJECT_ID>
  4. Enable Cloud Build API: The Cloud Build API must be enabled for the project.

    gcloud services enable cloudbuild.googleapis.com
  5. Permissions: Ensure the user or service account has the necessary permissions, such as roles/cloudbuild.builds.editor and roles/serviceusage.serviceUsageAdmin (to enable the API).

Core Concepts

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.

ConceptDescription
cloudbuild.yamlThe required configuration file that defines the build steps. It is written in YAML or JSON.
Build StepsA 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.
ArtifactsThe output of the build, typically a container image pushed to Google Container Registry (GCR) or Artifact Registry (AR), or other deployable files.
TriggersAutomation 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.

  1. Open the Cloud Console: Navigate to the Google Cloud Console.

  2. Go to Cloud Build: Use the search bar or the navigation menu to find Cloud Build.

  3. Select Build History: In the left navigation pane, select History (or use the direct URL: https://console.cloud.google.com/cloud-build/builds).

  4. 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 cb-list-build-zero-state skill). Note that region settings for triggers and builds are immutable after creation and must be chosen deliberately.

Creating a Basic Automated Trigger

This process defines an automation rule to run a build whenever code is pushed to a specified Git branch.

Step 1: Start Trigger Creation
  1. Navigate to the Cloud Build Triggers page (https://console.cloud.google.com/cloud-build/triggers).

  2. Click Create trigger.

Step 2: Configure Trigger Settings
  1. Name: Provide a unique, descriptive name (e.g., github-main-branch-build).

  2. Region: Select the region where the trigger configuration will be stored (e.g., global or a specific regional endpoint). Note: Trigger and build region settings are immutable after creation and must be chosen deliberately.

  3. Event: Select the event type. For automated CI/CD, select Push to a branch.

  4. Source: Select the repository source:

    • Repository: Connect your source repository (GitHub, Bitbucket, Cloud Source Repositories, etc.). If needed, authorize the connection.

    • Repository Name: Select the specific repository you want to link.

  5. Branch: Enter the branch pattern (e.g., ^main$ or ^develop).

Step 3: Configure Build Settings
  1. Configuration: Select Cloud Build configuration file (yaml or json).

  2. Location: Keep the default Repository and specify the path to your build configuration file (e.g., cloudbuild.yaml).

    • Alternative: For very simple builds, you can choose Inline to paste the YAML configuration directly into the trigger.

  3. (Optional) Service Account: For production environments, select a dedicated service account with limited permissions to enforce the principle of least privilege.

Step 4: Save and Test
  1. Click Create. The trigger is now active and will run automatically on the next matching Git push.

[!TIP] The cb-create-trigger skill provides detailed gcloud commands for creating triggers across all types (GitHub, Pub/Sub, Webhook) and configurations (inline, Dockerfile, YAML). Use that skill for CLI automation.

Running an Existing Trigger Manually

Sometimes you need to run a trigger on demand, outside of its normal automation flow (e.g., to rebuild an old commit or test a new substitution).

[!IMPORTANT] Substitution Immutability: You can only override values for substitution variables that are already defined in the trigger configuration. You cannot introduce new substitution variable keys at runtime.

Option A: Via the Cloud Console
  1. Navigate to the Cloud Build Triggers page (https://console.cloud.google.com/cloud-build/triggers).

  2. Locate the trigger you wish to run.

  3. Click the vertical ellipsis (⋮) next to the trigger and select Run.

  4. A dialog will appear, allowing you to specify:

    • Source branch/tag: Choose the specific Git reference to build from.

    • Substitution Variables: Override any existing substitution variables (e.g., set _VERSION to a new value).

  5. Click Run trigger. The build will start immediately, and you can monitor its status on the History page.

Option B: Via the gcloud CLI

Use the gcloud builds triggers run command to invoke the trigger and optionally override parameters.

# Run the trigger against the 'main' branch
gcloud builds triggers run <TRIGGER_NAME> \
    --region=<REGION> \
    --branch=main

# Run the trigger and override a substitution variable
gcloud builds triggers run <TRIGGER_NAME> \
    --region=<REGION> \
    --branch=main \
    --substitutions=_IMAGE_TAG="20231027-manual"

# Monitor the initiated build
# Note: The run command outputs the build ID. Use it to check status:
# gcloud builds log <BUILD_ID> --region=<REGION>

[!NOTE] The cb-run-trigger skill provides more complex invocation examples, including running against a specific commit SHA or using tags.

  • cb-create-trigger: Detailed CLI-focused instructions for creating all trigger types.

  • cb-list-build-zero-state: Advanced management of the Cloud Build dashboard and onboarding zero state.

  • cb-run-trigger: Comprehensive guide to manually running triggers using various gcloud options.

External Resources & Documentation

Files

references/cb-create-trigger.md


name: cb-create-trigger description: Creates a Cloud Build trigger to automate builds in response to repository events (pushes, tags, pull requests), Pub/Sub messages, Webhook events, or manual invocations. This skill covers all trigger types, repository services (GitHub, Cloud Source Repositories, Bitbucket, GitLab), and build configurations including YAML/JSON files, Dockerfiles, Buildpacks, and inline YAML.

Table of Contents

  • Preconditions (Lines 21-55)

  • Inputs (Lines 57-87)

  • Execution Steps (Lines 89-197)

    • Step 1: Authentication and Project Initialization (Lines 91-99)

    • Step 2: Enable Required APIs (Lines 101-107)

    • Step 3: Create the Trigger (Lines 109-182)

    • Step 4: Verification (Lines 184-197)

  • Outputs (Lines 199-209)

  • Related Skills (Lines 211-220)

Preconditions

  • Authentication: Run the following commands to ensure your CLI is authenticated with the correct credentials:

    gcloud auth login
    gcloud auth application-default login
  • Project ID: Ensure you have the projectId. If it is not already known, prompt the user to provide the project ID where the trigger will be created.

  • Enable APIs: Ensure the following APIs are enabled in your project:

    • cloudbuild.googleapis.com (Cloud Build API)

    • secretmanager.googleapis.com (Secret Manager API - required for Webhook triggers)

    • pubsub.googleapis.com (Cloud Pub/Sub API - required for Pub/Sub triggers)

  • IAM Roles: Ensure the user or service account has the following roles:

    • roles/cloudbuild.builds.editor (Cloud Build Editor)

    • roles/iam.serviceAccountUser (to use service accounts with the trigger)

    • roles/pubsub.subscriber (for the Cloud Build Service Agent if using Pub/Sub triggers)

    • roles/secretmanager.admin (if creating secrets for Webhook triggers)

  • Organization Policy: Be aware that organization policies (e.g., constraints/cloudbuild.allowedServiceAccounts or constraints/gcp.resourceLocations) may restrict service account selection or regional availability.

Inputs

NameTypeDescriptionRequired/OptionalDefault
nameStringA unique name for the trigger within the project's region. Must be alphanumeric and hyphens only.Required-
regionStringThe region where the trigger will be stored. Warning: Immutable after creation.Requiredglobal
descriptionStringA concise explanation of the trigger's purpose.Optional-
tagsListArbitrary strings used to organize and filter triggers.Optional-
event_typeEnumThe event that invokes the trigger: push_branch, push_tag, pull_request, manual, pubsub, webhook.Requiredpush_branch
repo_serviceEnumThe repository service: github, cloud_source_repositories, bitbucket, gitlab, developer_connect.Requiredgithub
repo_generationEnum1st_gen or 2nd_gen. Note: 2nd-gen is not available in the global region.Required1st_gen
repositoryStringName or resource path of the connected repository.Required-
branch_patternStringRegular expression to match branches (e.g., ^main$).Required for branch events-
tag_patternStringRegular expression to match tags (e.g., ^v.*).Required for tag events-
pull_request_patternStringRegular expression to match the base branch for pull requests.Required for PR events-
config_typeEnumyaml_json (Standard), dockerfile, buildpacks.Requiredyaml_json
config_sourceEnumrepository (File in repo) or inline (YAML provided directly).Requiredrepository
config_file_pathStringPath to the configuration file in the repository (e.g., cloudbuild.yaml).Required for repo configcloudbuild.yaml
inline_config_pathStringLocal path to a YAML/JSON file containing the build configuration to be embedded.Required for inline config-
dockerfileStringPath to the Dockerfile in the repository.Required for Docker buildsDockerfile
dockerfile_dirStringDirectory context for the Docker build.Optional/
dockerfile_imageStringDestination container image tag.Optional-
service_accountStringThe service account used for build execution. Strongly recommended for security.Optional (may be required by policy)-
substitution_variablesMapKey-value pairs for build parameterization (e.g., _DEPLOY_ENV=prod).Optional-
require_approvalBooleanWhether builds require manual approval before execution.Optionalfalse
pubsub_topicStringThe Pub/Sub topic to subscribe to.Required for Pub/Sub events-
webhook_secretStringSecret Manager secret version path (e.g., projects/.../secrets/.../versions/...).Required for Webhook events-
ignored_filesListGlob patterns for files that should not trigger builds.Optional-
included_filesListGlob patterns for files that MUST be changed to trigger builds.Optional-
cel_filterStringCommon Expression Language (CEL) filter for Pub/Sub or Webhook events.Optional-

Execution steps

Step 1: Authentication and Project Initialization

Ensure the environment is configured correctly.

gcloud auth login
gcloud auth application-default login
gcloud config set project <PROJECT_ID>
Step 2: Enable Required APIs

Enable services based on the chosen trigger type.

gcloud services enable cloudbuild.googleapis.com secretmanager.googleapis.com pubsub.googleapis.com
Step 3: Create the Trigger

Choose the subcommand based on the repo_service and event_type.

Option A: Create a GitHub Trigger (1st gen) Use this for standard continuous deployment from a GitHub repository.

gcloud builds triggers create github \
    --name=<NAME> \
    --region=<REGION> \
    --repo-owner=<REPO_OWNER> \
    --repo-name=<REPO_NAME> \
    --branch-pattern="<BRANCH_REGEX>" \
    --build-config="<CONFIG_FILE_PATH>" \
    --service-account="projects/<PROJECT_ID>/serviceAccounts/<SERVICE_ACCOUNT_EMAIL>" \
    --substitutions="\_KEY=VALUE" \
    --ignored-files="docs/**,README.md"

Option B: Create a Manual Trigger Use this for triggers that are only invoked on-demand or on a schedule.

gcloud builds triggers create manual \
    --name=<NAME> \
    --region=<REGION> \
    --repo="https://github.com/<OWNER>/<REPO>" \
    --repo-type=GITHUB \
    --branch="<BRANCH>" \
    --build-config="<CONFIG_FILE_PATH>"

Option C: Create a Webhook Trigger Use this to trigger builds via external HTTP POST requests. Requires a secret in Secret Manager.

gcloud builds triggers create webhook \
    --name=<NAME> \
    --region=<REGION> \
    --secret="projects/<PROJECT_ID>/secrets/<SECRET_NAME>/versions/<VERSION>" \
    --branch="<BRANCH>" \
    --repo="https://github.com/<OWNER>/<REPO>" \
    --repo-type=GITHUB \
    --build-config="<CONFIG_FILE_PATH>"

Option D: Create a Pub/Sub Trigger Use this to trigger builds in response to messages published to a topic.

gcloud builds triggers create pubsub \
    --name=<NAME> \
    --region=<REGION> \
    --topic="projects/<PROJECT_ID>/topics/<TOPIC_NAME>" \
    --branch="<BRANCH>" \
    --repo="https://github.com/<OWNER>/<REPO>" \
    --repo-type=GITHUB \
    --build-config="<CONFIG_FILE_PATH>"

Option E: Create a Trigger with Inline Configuration Use this to embed the build steps directly within the trigger instead of a file in the repository.

gcloud builds triggers create github \
    --name=<NAME> \
    --region=<REGION> \
    --repo-owner=<REPO_OWNER> \
    --repo-name=<REPO_NAME> \
    --branch-pattern="<BRANCH_REGEX>" \
    --inline-config="<LOCAL_PATH_TO_YAML>"
Step 4: Verification

Confirm the trigger has been created and is enabled.

gcloud builds triggers describe <NAME> --region=<REGION>

To list all triggers in a region:

gcloud builds triggers list --region=<REGION>

Outputs

NameDescription
trigger_nameThe unique name of the created trigger.
trigger_idThe system-generated UUID for the trigger.
webhook_urlThe URL used to invoke a Webhook trigger (includes the key
: : and secret placeholders). :
topic_nameThe Pub/Sub topic associated with the trigger (if
: : applicable). :
regionThe location where the trigger resource resides.
  • cb-run-trigger: Manually invoke an existing trigger with revision overrides.

  • secret-manager-create-secret: Create and manage secrets for Webhook authentication.

  • pubsub-create-topic: Create topics for Pub/Sub triggers or build notifications.

  • cloud-build-create-worker-pool: Create private worker pools for regional builds.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs a command-line tool

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Google
Publisher
Google (Official)
Source
google/skills · skills/cloud/cloud-build-basics · commit 2194d3b
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google or Google.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cloud-build-basics.zip