
cloud-build-investigation
by palladius
Ricc's golden custom commands
SKILL.md
name: cloud-build-investigation description: | Expert-level SRE skill for Google Cloud Build (GCB) and Cloud Run investigations. Activate when user mentions Cloud Build failures, deployment issues to Cloud Run, or needs help debugging GCB pipelines. Specializes in correlating git commits with build failures, analyzing build logs, and providing systematic debugging workflows.
Cloud Build Investigation Skill
This skill provides expert-level SRE capabilities for investigating and debugging Google Cloud Build (GCB) issues, particularly for deployments to Cloud Run.
When to Activate
Use this skill when:
- User mentions Cloud Build failures or errors
- Debugging deployment issues to Cloud Run
- Investigating why a build/deployment stopped working
- Correlating git commits with build failures
- Setting up or troubleshooting Cloud Build pipelines
- Adding environment variables to Cloud Build/Cloud Run
Core Principles
⚠️ CRITICAL: Assume positive intention!
- If a
cloudbuild.yamlexists with a trigger, DO NOT MOVE OR MAJORLY CHANGE IT - The user (likely Riccardo) may have spent hours making it work
- Take baby steps and minimize mutations
- Changing folder targets or major refactoring will likely break things further
Investigation Workflow
Step 1: Gather Build History
- Run
just git-logs-timestampedto get compact commit history with timestamps (YYYYMMDD HH:MM) - Run
just cloud-build-listto get recent Cloud Builds - Identify N successful builds and M failed builds
- Focus on the FIRST failing build (this is key!)
Step 2: Analyze the Failure
- Use
just cloud-build-show-log FIRST_FAILING_BUILD_IDto examine logs - Cross-correlate with git commits via timestamps
- Cross-reference with the VERSION file (Carlessian standard)
- Identify the exact commit that introduced the failure
Step 3: Root Cause Analysis
Cross-correlate failed build logs with the git diff of the culprit commit:
- Was it a Dockerfile change?
- A dependency update (Gemfile/requirements.txt/package.json)?
- A configuration change?
- An environment variable issue?
Step 4: Corrective Action
If investigation shows NO errors → Done! ✅
If errors found:
-
File GitHub Issue:
- Title:
[failed Cloud Build] <BUILD_ID> <SHORT_DESCRIPTION> - BUILD_ID in title enables deduplication
- Post the git log list (enables GH to link commits visually)
- Title:
-
Investigate & Propose Fix:
- Document findings in the issue
- Propose a fix with user collaboration
-
Test with Baby Steps:
- Cloud Build tests require small commit/pushes
- Version bumps:
1.2.3→1.2.3a→1.2.3b(for quick testing) - Each build takes 5-6 minutes
- Consider combining with minor UI/UX improvements for time efficiency
-
Monitor:
- Keep checking build status every 2 minutes
- Use
just cloud-build-listandjust cloud-build-show-log {{build_id}}
Required Justfile Targets
Ensure the project's justfile has these targets (adapt PROJECT_ID and CLOUD_RUN_ENDPOINT):
# List latest 10 CB builds, possibly the first might still be running
cloud-build-list:
gcloud builds list --project=PROJECT_ID --limit=10
# Show the log of a specific Cloud Build, eg 7c82188e-485a-4735-a70d-fb303fbfe5a0
cloud-build-show-log build_id:
@echo "Showing log for build ID: {{build_id}}. Use --stream to follow the log indefinitely (you can do it, but I want Gemini NOT to do it)."
gcloud builds log {{build_id}} --project=PROJECT_ID
# Show Cloud Run logs
cloud-run-logs:
@echo "☁️ Fetching logs for Cloud Run environment..."
gcloud logging read "resource.type=cloud_run_revision AND resource.labels.service_name=CLOUD_RUN_ENDPOINT" --project=PROJECT_ID --limit=100 --format="value(timestamp, severity, textPayload)"
# Shows git logs in timestamped way
git-logs-timestamped:
git log --pretty=format:'%h %ad | %s%d [%an]' --date=iso -n 10
Note: If just is not available, use a Makefile instead (convert N spaces to tabs).
Adding Environment Variables
This is a complex process. Follow carefully:
- Add variable to the script (usually in
bin/with "cloud build" in name)- Example:
bin/ricc-cb-push-to-cloudrun-magic.sh
- Example:
- Ensure the variable is passed from Cloud Build in the step that calls it
- Update the Cloud Run trigger for this service
- Should be documented in
README.md(if not, document it!)
- Should be documented in
- Check
gcp/oriac/folders for additional hints
File Structure
If Cloud Build is set up, expect:
cloudbuild.yaml(root file, likely has trigger attached)- Possibly
bin/scripts for deployment - Possibly
gcp/oriac/folders with infrastructure code
Resources
- Scripts: Check
.gemini/skills/cloud-build-investigation/scripts/for helper utilities - References: See
.gemini/skills/cloud-build-investigation/references/for GCP docs
Important Reminders
🚫 DO NOT:
- Change
cloudbuild.yamllocation or major structure - Modify
buildtarget injustfilewithout understanding full context - Make sweeping changes to folder structures
- Auto-stream logs indefinitely (use
--streamcautiously)
✅ DO:
- Take baby steps
- Test incrementally
- Document findings in GitHub issues
- Collaborate with the user (Riccardo)
- Cross-correlate timestamps between git and Cloud Build
- Use VERSION file for additional context
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です