Cloud Build Basics

Cloud Build Basics

Teaches a coding agent the basics of Google Cloud Build: enabling the API, finding build history, and creating and manually running a build trigger.

Skill files5 files

references/

SKILL.md156 lines
1
---
2
name: cloud-build-basics
3
metadata:
4
version: "1.0.3"
5
category: DevOps
6
description: >-
7
Teaches the fundamentals of Cloud Build on Google Cloud. Covers core concepts,
8
API enablement, console navigation to the Build History page, and the end-to-end
9
workflow for creating and manually running a basic build trigger. Do not use for
10
managing private pools or complex pipeline architectures.
11
---
12
13
# Cloud Build Basics
14
15
## Attribution
16
17
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
18
MUST read [Usage Attribution](references/attribution.md). For commands executed
19
directly in the terminal (never in generated scripts, Terraform, or user code),
20
prefix `gcloud` with
21
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-build-basics)"`
22
and append `agent-skills/1.0 (skill:cloud-build-basics)` to `User-Agent` headers.
23
24
## Prerequisites
25
26
Before starting, ensure the following prerequisites are met:
27
28
1. **Google Cloud SDK**: Ensure the [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) is installed and configured.
29
2. **Authentication**: Authenticate the gcloud CLI:
30
```bash
31
gcloud auth login
32
gcloud auth application-default login
33
```
34
3. **Project ID**: Know the target Google Cloud Project ID. Set the context:
35
```bash
36
gcloud config set project <PROJECT_ID>
37
```
38
4. **Enable Cloud Build API**: The Cloud Build API must be enabled for the project.
39
```bash
40
gcloud services enable cloudbuild.googleapis.com
41
```
42
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).
43
44
## Core Concepts
45
46
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.
47
48
| Concept | Description |
49
| :--- | :--- |
50
| **`cloudbuild.yaml`** | The required configuration file that defines the build steps. It is written in YAML or JSON. |
51
| **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. |
52
| **Artifacts** | The output of the build, typically a container image pushed to Google Container Registry (GCR) or Artifact Registry (AR), or other deployable files. |
53
| **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. |
54
55
## Navigation: Viewing Build History
56
57
The Cloud Build Build History page is the central place to monitor the status of past and ongoing builds.
58
59
1. **Open the Cloud Console**: Navigate to the Google Cloud Console.
60
2. **Go to Cloud Build**: Use the search bar or the navigation menu to find **Cloud Build**.
61
3. **Select Build History**: In the left navigation pane, select **History** (or use the direct URL: `https://console.cloud.google.com/cloud-build/builds`).
62
4. **Review Builds**:
63
* **Status**: Check the status column (`SUCCESS`, `FAILURE`, `WORKING`, `QUEUED`).
64
* **Region**: Use the region filter at the top to view builds that ran in a specific region (important for regional worker pools).
65
* **Logs**: Click on a specific Build ID to view the detailed logs, execution steps, and build summary. This is crucial for debugging failed builds.
66
67
> [!NOTE]
68
> 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`](references/cb-list-build-zero-state.md) skill). Note that region settings for triggers and builds are immutable after creation and must be chosen deliberately.
69
70
## Creating a Basic Automated Trigger
71
72
This process defines an automation rule to run a build whenever code is pushed to a specified Git branch.
73
74
### Step 1: Start Trigger Creation
75
76
1. Navigate to the **Cloud Build Triggers** page (`https://console.cloud.google.com/cloud-build/triggers`).
77
2. Click **Create trigger**.
78
79
### Step 2: Configure Trigger Settings
80
81
1. **Name**: Provide a unique, descriptive name (e.g., `github-main-branch-build`).
82
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.**
83
3. **Event**: Select the event type. For automated CI/CD, select **Push to a branch**.
84
4. **Source**: Select the repository source:
85
* **Repository**: Connect your source repository (GitHub, Bitbucket, Cloud Source Repositories, etc.). If needed, authorize the connection.
86
* **Repository Name**: Select the specific repository you want to link.
87
5. **Branch**: Enter the branch pattern (e.g., `^main$` or `^develop`).
88
89
### Step 3: Configure Build Settings
90
91
1. **Configuration**: Select **Cloud Build configuration file (yaml or json)**.
92
2. **Location**: Keep the default **Repository** and specify the path to your build configuration file (e.g., `cloudbuild.yaml`).
93
* *Alternative*: For very simple builds, you can choose **Inline** to paste the YAML configuration directly into the trigger.
94
3. **(Optional) Service Account**: For production environments, select a dedicated service account with limited permissions to enforce the principle of least privilege.
95
96
### Step 4: Save and Test
97
98
1. Click **Create**. The trigger is now active and will run automatically on the next matching Git push.
99
100
> [!TIP]
101
> 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.
102
103
## Running an Existing Trigger Manually
104
105
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).
106
107
> [!IMPORTANT]
108
> **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.
109
110
### Option A: Via the Cloud Console
111
112
1. Navigate to the **Cloud Build Triggers** page (`https://console.cloud.google.com/cloud-build/triggers`).
113
2. Locate the trigger you wish to run.
114
3. Click the vertical ellipsis (⋮) next to the trigger and select **Run**.
115
4. A dialog will appear, allowing you to specify:
116
* **Source branch/tag**: Choose the specific Git reference to build from.
117
* **Substitution Variables**: Override any existing substitution variables (e.g., set `_VERSION` to a new value).
118
5. Click **Run trigger**. The build will start immediately, and you can monitor its status on the **History** page.
119
120
### Option B: Via the gcloud CLI
121
122
Use the `gcloud builds triggers run` command to invoke the trigger and optionally override parameters.
123
124
```bash
125
# Run the trigger against the 'main' branch
126
gcloud builds triggers run <TRIGGER_NAME> \
127
--region=<REGION> \
128
--branch=main
129
130
# Run the trigger and override a substitution variable
131
gcloud builds triggers run <TRIGGER_NAME> \
132
--region=<REGION> \
133
--branch=main \
134
--substitutions=_IMAGE_TAG="20231027-manual"
135
136
# Monitor the initiated build
137
# Note: The run command outputs the build ID. Use it to check status:
138
# gcloud builds log <BUILD_ID> --region=<REGION>
139
```
140
141
> [!NOTE]
142
> The `cb-run-trigger` skill provides more complex invocation examples, including running against a specific commit SHA or using tags.
143
144
## Related Skills
145
146
* [`cb-create-trigger`](references/cb-create-trigger.md): Detailed CLI-focused instructions for creating all trigger types.
147
* [`cb-list-build-zero-state`](references/cb-list-build-zero-state.md): Advanced management of the Cloud Build dashboard and onboarding zero state.
148
* [`cb-run-trigger`](references/cb-run-trigger.md): Comprehensive guide to manually running triggers using various `gcloud` options.
149
150
## External Resources & Documentation
151
152
* [Cloud Build Documentation](https://cloud.google.com/build/docs)
153
* [Cloud Build Configuration File Schema](https://cloud.google.com/build/docs/build-config-file-schema)
154
* [Automating Builds with Triggers](https://cloud.google.com/build/docs/automating-builds/create-manage-triggers)
155
* [gcloud CLI builds Reference](https://cloud.google.com/sdk/gcloud/reference/builds)
156

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…