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.
Integrations
Azure DevOps
Slack Bot
Type
Categories
- Engineering
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.
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).
How to customize it
- 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.
Use cases
- Notifications & Alerts