# Buildkite build failing notifications on your phone > Get an early High-priority push notification the moment a Buildkite build starts failing, while its other jobs are still running. - Company: Buildkite (https://www.justpush.io/recipes/buildkite) - Event: `build.failing` (build.failing) - Tags: CI/CD, Builds & CI - Install: https://studio.justpush.io/recipes/buildkite/build-failing - Web page: https://www.justpush.io/recipes/buildkite/build-failing ## Setup 1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL. 2. In Buildkite, go to Settings > Notification Services and click Add on Webhook. 3. Enter a description and paste your webhook URL (shown in Studio after install) as the Webhook URL. 4. Tick the build.failing event, choose which pipelines (and branches) to watch, and click Add Webhook Notification. 5. In **Settings → Notification Services**, add a **Webhook** with the URL above and tick **build.failing**. Pick the pipelines to watch, and optionally a branch filter such as `main`. 6. Buildkite sends `build.failing` as soon as a job fails hard (not a soft failure), while the build's other jobs keep running. It doesn't tell you when the build finally ends: add the **Build finished** recipe for that, keeping in mind that a failed build then pushes twice (once from each). 7. Saving the webhook sends a ping, which gives a quiet **🔔 Buildkite connected** push. 8. Buildkite sends your webhook token as `X-Buildkite-Token` (or an HMAC-SHA256 `X-Buildkite-Signature`), but JustPush doesn't check it yet, so keep your endpoint URL private. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // Buildkite → build.failing // Fires as soon as a job fails in a Buildkite build that's still running, so you hear about // a broken build before the rest of its jobs have finished. // Docs: https://buildkite.com/docs/apis/webhooks/pipelines/build-events // Header names can arrive in any case. function header(request, name) { const headers = request.headers || {} const key = Object.keys(headers).find((k) => k.toLowerCase() === name) const value = key ? headers[key] : null return Array.isArray(value) ? value[0] : value } // Treat blank or non-string values as missing. function text(value) { if (typeof value === "number" && Number.isFinite(value)) return String(value) return typeof value === "string" && value.trim() ? value.trim() : null } // Only link to real http(s) URLs. function link(url, cta) { return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : [] } function handleRequest(request) { const body = request.body && typeof request.body === "object" ? request.body : {} // Buildkite sends X-Buildkite-Event, and the same name in the body's "event" field. const event = header(request, "x-buildkite-event") ?? (typeof body.event === "string" ? body.event : null) // Saving the webhook's settings sends a ping; confirm the connection quietly. if (event === "ping") { return { title: "🔔 Buildkite connected", message: `Webhook for ${text(body.organization?.name) ?? "your organization"} is working`, topic: "Buildkite", priority: -1, } } // Guard: only build.failing. const build = body.build if (event !== "build.failing" || !build || typeof build !== "object") { console.log(`Ignoring Buildkite "${event ?? "unknown"}" event`) return null } const pipeline = text(body.pipeline?.name) ?? "Pipeline" const number = text(build.number) const subject = (text(build.message) ?? "").split("\n")[0] const who = text(build.creator?.name) return { title: `⚠️ ${pipeline}${number ? ` #${number}` : ""} is failing`, message: (text(build.branch) ?? "A build") + (subject ? ` — ${subject}` : "") + (who ? ` (${who})` : ""), topic: "Buildkite", priority: 1, // a job has failed hard: the build is broken and needs you soon buttons: link(build.web_url, "View build"), } } ``` ## Buildkite build.failing webhook payload (sample) ```json { "build": { "id": "f62a1b4d-10f9-4790-bc1c-e2c3a0c80983", "env": [], "url": "https://api.buildkite.com/v2/organizations/acme/pipelines/web/builds/1482", "state": "failing", "branch": "main", "commit": "abcd0b72a1e580e90712cdd9eb26d3fb41cd09c8", "number": 1482, "source": "webhook", "blocked": false, "creator": { "id": "3d3c3bf0-7d58-4afe-8fe7-b3017d5504de", "name": "Jane Doe", "email": "jane@example.com", "avatar_url": "https://www.gravatar.com/avatar/00000000000000000000000000000000", "created_at": "2025-05-22T12:36:45.309Z" }, "message": "Fix checkout totals rounding\n\nCloses #88", "web_url": "https://buildkite.com/acme/web/builds/1482", "meta_data": [], "created_at": "2026-09-24T21:05:59.874Z", "failing_at": "2026-09-24T21:07:31.204Z", "graphql_id": "QnVpbGQtLS1mNjJhMWI0ZC0xMGY5LTQ3OTAtYmMxYy1lMmMzYTBjODA5ODM=", "started_at": "2026-09-24T21:06:10.112Z", "finished_at": null, "pull_request": null, "scheduled_at": "2026-09-24T21:05:59.874Z", "cancel_reason": null }, "event": "build.failing", "sender": { "id": "8a7693f8-dbae-4783-9137-84090fce9045", "name": "Jane Doe" }, "pipeline": { "id": "849411f9-9e6d-4739-a0d8-e247088e9b52", "url": "https://api.buildkite.com/v2/organizations/acme/pipelines/web", "name": "Web", "slug": "web", "web_url": "https://buildkite.com/acme/web", "repository": "git@github.com:acme/web.git", "default_branch": "main" } } ``` ## FAQ ### Does this work on iPhone and Android? Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification. ### Do I need to write code? No. Install the recipe in Studio, paste your webhook URL into Buildkite and you are done. The code is there if you want to change the text, the sound or the buttons. ### Can I change what the notification says? Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save. ### What does it cost? JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.