---
name: azure-devops-failed-pipelines
description: "Each weekday morning: Azure Pipelines runs that failed on main since yesterday, with the failing stage, task and first error, and whether main is still red. Use when the user asks for this, or when it runs on a schedule."
---

# Azure DevOps failed pipelines

Each weekday morning: Azure Pipelines runs that failed on main since yesterday, with the failing stage, task and first error, and whether main is still red.

Azure DevOps emails the person who queued a failed run, and the Pipelines page shows a red icon per definition without saying which of twelve stages failed or why. Finding the real error means opening the run, expanding the job and scrolling a long log.

The agent does that walk through the build timeline for every failed run on main, takes the first error the failing task reported, and checks whether a later run passed. The card lists only what is broken now, with the error text and who triggered it.

## Two ways to get the data

Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.

## Route A: API or MCP server

### What you need

- A personal access token with Build (Read) scope (`vso.build`) in `AZURE_DEVOPS_PAT`, and the organization and project names.
- Or the Azure DevOps MCP server (`https://mcp.dev.azure.com/{organization}`) in read-only mode.

If something is missing, say what and stop; do not invent numbers.

### Steps

1. **List failed runs on main** (Azure DevOps): Per project: `GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?branchName=refs/heads/main&resultFilter=failed&minTime=<24 hours ago>&queryOrder=finishTimeDescending&api-version=7.1`. Keep `id`, `definition.name`, `sourceVersion`, `requestedFor.displayName` and `finishTime`.
2. **Walk the timeline** (Azure DevOps): `GET .../_apis/build/builds/{buildId}/timeline?api-version=7.1` returns stages, jobs and tasks as records. Take the records with `result` `failed`, follow `parentId` up to name the stage and job, and read the task's `issues` where `type` is `error`.
3. **Get the error lines** (Azure DevOps): When `issues` is empty or vague, fetch the failing task's log from `log.url` and keep the first lines that contain `##[error]`, plus the two lines before them.
4. **Check whether main is still red** (Azure DevOps): Query the same definition with `definitions={id}&branchName=refs/heads/main&$top=1&queryOrder=finishTimeDescending`. If the newest completed run `succeeded`, mark the failure as fixed.
5. **Report**: Still-failing pipelines first, each with stage, task, the first error line, the commit and who triggered it; fixed ones after in one line each.

## Route B: the browser

### What you need

- Signed in to Azure DevOps with an account that can view builds in the project (Basic or Stakeholder access with Build read permission).

If something is missing, say what and stop; do not invent numbers.

### Steps

Start at https://dev.azure.com/. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.

1. **Open the project's pipeline runs**: Pick the organization and project, then **Pipelines > Pipelines** in the left menu and the **Runs** tab, which lists runs across every pipeline in the project, newest first.
2. **Filter to failed runs on main**: Open the filter (funnel icon) and set **Branch** to `main` and **Status** to `Failed`. Keep the runs that finished in the last 24 hours; each row shows the pipeline name, the commit message, who triggered it and the finish time.
3. **Find the failing stage and task**: Open a run. The **Summary** tab lists **Errors** with the message and the task they came from, and the stage view shows which stage went red. Click the failed job and the failed task to open its log and copy the first `##[error]` line with the two lines before it.
4. **Check whether main is still red**: Open the pipeline itself (click its name) and look at the newest run on `main`. If it succeeded, the failure is fixed; if it failed on the same task, main is still red.
5. **Report**: Still-failing pipelines first with stage, task, error line, commit and who triggered it; fixed ones after in one line each. A task that failed more than twice this week is a repeat offender.

Note: One project per pass; with several projects, repeat the steps for each. Classic release pipelines are not in the Runs list, which matches the API route. Task logs open in a viewer that loads long logs in chunks, so wait for the end before reading.

## The report

- **Still failing on main**: pipeline, stage, task, first error line, commit, who triggered it.
- **Fixed since**: failures a later run cleared.
- **Repeat offenders**: tasks that failed more than twice this week.
- One line on the first thing to check.

## Post it to Briefkin

When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.

```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
  -H "authorization: Bearer $BRIEFKIN_TOKEN" \
  -H "content-type: application/json" \
  -d @- <<'JSON'
{
  "v": 1,
  "event_id": "azure-devops-failed-pipelines/<date of this run, e.g. 2026-10-16>",
  "item_key": "azure-devops-failed-pipelines",
  "project": "Acme",
  "source": "Azure DevOps failed pipelines skill",
  "kind": "update",
  "title": "Main is failing in the Test stage",
  "summary": "**2** pipelines failed on main since yesterday morning. **acme-api-ci** is still red: Test stage, task `dotnet test`, triggered by Priya at 17:42.",
  "work_state": "failed",
  "widget": [
    {
      "type": "Steps",
      "props": {
        "items": [
          {
            "label": "Build",
            "state": "done"
          },
          {
            "label": "Test: dotnet test",
            "state": "failed",
            "note": "OrderServiceTests.Refund_IsIdempotent: expected 1 refund, found 2"
          },
          {
            "label": "Publish artifacts",
            "state": "skipped"
          },
          {
            "label": "Deploy to staging",
            "state": "skipped"
          }
        ]
      }
    },
    {
      "type": "Table",
      "props": {
        "columns": [
          "Pipeline",
          "Commit",
          "Triggered by",
          "Now"
        ],
        "rows": [
          [
            "acme-api-ci",
            "a17c9e0",
            "Priya",
            "Still failing"
          ],
          [
            "acme-web-ci",
            "3be4f21",
            "Tom",
            "Fixed at 21:05"
          ]
        ]
      }
    }
  ]
}
JSON
```

Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.

## Run it on a schedule

Suggested: Weekdays at 8:00 (`0 8 * * 1-5`). From cron, with the agent signed in on that machine:

```bash
0 8 * * 1-5 claude -p "Run the azure-devops-failed-pipelines skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```

Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/azure-devops-failed-pipelines#schedule

Source: https://briefkin.dev/skills/azure-devops-failed-pipelines
