# Instant Slack alert when an Azure DevOps build fails

> When a pipeline build fails, we post a tight Slack card naming who pushed, the likely cause, and a link to the build so on-call can triage in seconds.

- Workflow type: agent
- Services: Azure DevOps, Slack Bot
- Categories: Engineering
- Published: 2026-07-17

## What it does

- Watches your Azure DevOps pipelines and fires the moment a build finishes with a failed result.
- Reads the failing step's logs and looks up the commit that triggered the build to work out what broke and who pushed it.
- Posts a short, skimmable Slack card to your engineering channel with the committer, the likely fix area, and a link straight to the build.
- Lets whoever is on call start triaging in seconds instead of digging through the pipeline UI.

## What you'll need

- An Azure DevOps organization with the pipelines you want to monitor.
- A Slack workspace with our bot added to your engineering channel.
- Azure DevOps set to notify this workflow when a build completes (a built-in Azure DevOps service hook, which we help you point at the workflow).

## Prompt

When Azure DevOps sends a Build completed service hook and the build finished with a failed result, run this workflow. Only act on failures; ignore builds that succeeded, were canceled, or partially succeeded.

Start by calling Azure DevOps Get Build with the build id from the event to load the full build record: the pipeline (build definition) name, the overall result and which stage or job failed, the source branch, the requested-for user, the source commit id, and the build's web link.

Then call Azure DevOps Get Build Logs to read the output of the failing step. List the build's logs, find the log for the stage or task that failed, and read the tail of it so you can pull out the actual error message or stack trace.

Next call Azure DevOps Get Commit with the build's source commit id and include the change list, so you can see who pushed the change, the commit message, and which files were modified.

Using everything you gathered, identify the failing stage and reason about the single most likely cause in plain language. Tie the error in the logs to the files that changed in the commit when you can, and name a probable fix area, for example a failing test file, a dependency install step, a lint rule, or a broken database migration.

Finally, send the alert to the engineering channel with Slack Bot Send a Message. Format it as a tight, skimmable card using Slack mrkdwn: a bold headline with the pipeline name and a clear FAILED label, the failing stage, the committer's name, a one line summary of the probable cause and fix area, the branch and short commit id, and a link to the build. Keep it short enough that whoever is on call can triage in seconds without opening the pipeline UI.

## How to customize

- Send alerts to one engineering channel, or route different pipelines to different team channels.
- Change which builds trigger an alert, for example only your main branch or release pipelines.
- Adjust the card wording or tone, or add a mention for whoever is on call.

## FAQ

### Does this only alert on failed builds?

Yes. It only fires when a build finishes with a failed result, so your channel stays quiet unless something actually breaks.

### How does it know who to notify?

It looks up the commit that triggered the build and names the person who pushed it, along with the files that changed, so the right engineer sees it first.

### Will it tell me what went wrong?

It reads the failing step's output and summarizes the most likely cause in plain language, then points to the area to look at first.

### Do I have to open Azure DevOps to see the details?

No. The alert includes a direct link to the build, but the card itself is built to give on-call enough context to start triaging right away.

### Can I send alerts to more than one channel?

Yes. You can post to a single engineering channel or split alerts across teams based on which pipeline failed.

Use this prompt in General Input: https://www.generalinput.com/prompts/instant-slack-alert-when-an-azure-devops-build-fails