Overview

Send Cloud Build results to Callgoose SQIBS. Cloud Build publishes every build update to Pub/Sub; the Cloud Build HTTP notifier, a small Cloud Run service, turns the ones you choose into a JSON POST to your SQIBS API endpoint. SQIBS opens an incident when a triggered build fails and resolves it when the same trigger builds successfully.

You need
A Google Cloud project with Cloud Build triggers, permission to deploy Cloud Run and Pub/Sub, and a SQIBS API token
Setup time
About 20 minutes
Result
Failed builds open SQIBS incidents; green builds resolve them

How it works

Cloud Build
Alert fires
A triggered build fails or times out.
Cloud Build
Sends a webhook
The HTTP notifier posts your JSON template.
SQIBS
API filter matches
The filter decides whether to open or resolve, and the priority.
SQIBS
Incident opens
FAILURE opens it, SUCCESS on the same trigger closes it.

Want SQIBS to fix known issues before anyone is paged? See Fix known issues automatically.

Step 1: Add the API filter in SQIBS

  1. In SQIBS, open Services, choose the service that should receive these incidents, and click Add Or Update API Integration.
  2. Add a filter with these values (there is no built-in Cloud Build template yet, so enter them by hand):
Part Payload JSON key Key value contains What it does
Trigger "status" FAILURE Opens an incident for a failed build.
Resolve "status" SUCCESS Resolves the open incident.
Match "triggerId" Ties the next build of the same trigger to the incident.
Title from "logUrl" Links straight to the build log.
  1. Choose the Priority for these incidents and click Save.

To page on timeouts too, add a second filter with the same values and TIMEOUT instead of FAILURE. (Values in one Key value contains must all match, so each status needs its own filter.)

Not sure of a key? Send one test message first (step below), then build the filter from the real payload.

Find the right key with the JSON key creator
In the API Integration window, click the round {} button at the bottom right. Paste a payload that SQIBS received (copy it from the API log). SQIBS lists every key with its value, each with a copy button. Copy the key into Payload JSON key and the value into Key value contains. No need to read the JSON by hand.

Step 2: Write the notifier config and template

  1. Create a Cloud Storage bucket for the notifier files.
  2. Save this as callgoose-sqibs.yaml. The filter sends only builds started by a trigger that end in success, failure or timeout:
apiVersion: cloud-build-notifiers/v1
kind: HTTPNotifier
metadata:
  name: callgoose-sqibs-notifier
spec:
  notification:
    filter: build.build_trigger_id != "" && build.status in [Build.Status.SUCCESS, Build.Status.FAILURE, Build.Status.TIMEOUT]
    delivery:
      url: https://<your-endpoint>/sqibs-api/v1/process?from=cloudbuild&token=<your-token>
    template:
      type: golang
      uri: gs://BUCKET_NAME/callgoose-sqibs.json

Replace <your-endpoint> and <your-token> with the values from your SQIBS account. See how to get the endpoint URL and API tokens.

  1. Save this as callgoose-sqibs.json. It is the body the notifier posts, so the filter keys in step 1 match it exactly:
{
  "status": "{{.Build.Status}}",
  "buildId": "{{.Build.Id}}",
  "triggerId": "{{.Build.BuildTriggerId}}",
  "projectId": "{{.Build.ProjectId}}",
  "logUrl": "{{.Build.LogUrl}}"
}

Step 3: Deploy the notifier

Run these with your bucket, project, Cloud Run service URL and the Pub/Sub service account (the Cloud Build docs show how to grant it the Cloud Run Invoker role):

gcloud storage cp callgoose-sqibs.yaml callgoose-sqibs.json gs://BUCKET_NAME/

gcloud run deploy callgoose-sqibs-notifier \
  --image=us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/http:latest \
  --no-allow-unauthenticated \
  --update-env-vars=CONFIG_PATH=gs://BUCKET_NAME/callgoose-sqibs.yaml,PROJECT_ID=PROJECT_ID

gcloud pubsub topics create cloud-builds

gcloud pubsub subscriptions create callgoose-sqibs-builds \
  --topic=cloud-builds \
  --push-endpoint=SERVICE_URL \
  --push-auth-service-account=SUB_IDENTITY_SERVICE_ACCOUNT@PROJECT_ID.iam.gserviceaccount.com

Step 4: Test it

The API log saves payloads only while API Tracking is on for the token. Turn it on under API Tokens before you test; it switches itself off after 48 hours.

  1. Run a trigger whose build fails, for example by pushing a commit that breaks a test.
  2. In SQIBS, a new incident opens. The payload looks like this:
{
  "status": "FAILURE",
  "buildId": "6b1a7c2e-0f3d-4b8e-9a51-2d7c0e4f9a10",
  "triggerId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "projectId": "shop-prod",
  "logUrl": "https://console.cloud.google.com/cloud-build/builds/6b1a7c2e-0f3d-4b8e-9a51-2d7c0e4f9a10?project=shop-prod"
}
  1. Fix the build and run the trigger again. When it ends in SUCCESS, SQIBS resolves the incident.

No incident? Open the API log (with API Tracking on). If the payload is there, the filter did not match it: paste it into the JSON key creator and check the keys. If it is not there, check the URL and token in the notifier config (and the Cloud Run logs).

Fix known issues automatically

Many alerts have a known fix: restart a service, clear a full disk, run a health check. SQIBS can run that fix for you the moment the incident opens. This is event-driven auto remediation. For example, when a deploy build fails, SQIBS can run a workflow that checks the running service and rolls it back to the last good revision.

Incident opens
Workflow starts
SQIBS runs the automation workflow linked to the filter.
Fixed
Incident resolved
The issue is fixed before anyone has to step in.
Not fixed
Escalated to the engineer
After the waiting time you set, the escalation policy pages on-call as usual.

Safe by design. SQIBS runs only workflows your own engineers wrote and approved for your environment. Nothing is guessed or generated: the same steps an engineer would run by hand, run sooner. If the workflow does not fix the issue, the engineer is paged as usual.

To set it up, in the same API filter:

  1. Select Workflow: choose the automation workflow to run when this filter opens an incident.
  2. If success then make incident resolved: turn on to resolve the incident when the workflow succeeds.
  3. Waiting time for escalate to escalation policies: how many minutes to give the workflow before paging the on-call engineer.

Start with low-risk workflows, such as a health check, and add fixes as you come to trust them.

Learn more: