Service Hooks in Azure DevOps for Test Automation
How to use Azure DevOps Service Hooks to trigger test automation, send notifications, and integrate with external tools. Covers webhook configuration, build completion hooks, Teams/Slack notifications, and custom event handlers.
Service Hooks let Azure DevOps send events to external systems when something happens — a build completes, a test run finishes, a bug is created. For QA teams, this enables automated notifications, external system triggers, and event-driven workflows.
What Service Hooks can trigger on
| Event | QA relevance |
|---|---|
| Build completed | Test run finished — notify QA team |
| Release completed | Deployment done — start post-deploy tests |
| Work item created | New bug — notify responsible developer |
| Work item state changed | Bug resolved — prompt QA to verify |
| Pull request created | Trigger external code review tool |
Setting up Service Hooks
- Go to Project Settings → Service hooks → + Create subscription
- Select the service: Teams, Slack, WebHooks, etc.
- Select the event trigger
- Configure filters (e.g., only trigger when pipeline fails)
- Configure the target (webhook URL, channel, etc.)
Microsoft Teams notifications
The most common QA use case: notify the team when the regression pipeline fails.
-
In Teams, create an Incoming Webhook for your QA channel:
- Channel → More options → Connectors → Incoming Webhook → Add
- Copy the webhook URL
-
In Azure DevOps: Service Hooks → New → Microsoft Teams
-
Event: Build completed
-
Filters:
- Pipeline:
Nightly Regression - Status:
Failed
- Pipeline:
-
Action: post the webhook URL
The notification includes: build number, failed stage, and a direct link to the test results.
Slack notifications
Similar to Teams. Generate a Slack Incoming Webhook from your workspace:
- Service Hooks → New → Slack
- Event: Build completed
- Webhook URL: your Slack channel webhook
Customise the message format using Slack's Block Kit in the webhook payload.
Custom webhooks for test automation triggers
Trigger a test run on an external system when a deployment completes:
// Webhook payload sent by Azure DevOps when release completes
{
"eventType": "ms.vss-release.release-deployment-completed-event",
"resource": {
"environment": {
"name": "Staging"
},
"release": {
"name": "Release-47",
"webAccessUri": "https://dev.azure.com/..."
}
}
}Your external test trigger service receives this webhook and starts the appropriate test suite.
Receiving webhooks in Azure Functions
// Azure Function that receives the webhook and triggers tests
import { app, HttpRequest, HttpResponseInit } from '@azure/functions'
app.http('triggerTests', {
methods: ['POST'],
handler: async (request: HttpRequest): Promise<HttpResponseInit> => {
const payload = await request.json()
const environment = payload.resource.environment.name
if (environment === 'Staging') {
// Trigger the test pipeline via Azure DevOps REST API
await fetch(
`https://dev.azure.com/${ORG}/${PROJECT}/_apis/pipelines/${PIPELINE_ID}/runs?api-version=7.1`,
{
method: 'POST',
headers: {
Authorization: `Basic ${Buffer.from(`:${PAT}`).toString('base64')}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
resources: { repositories: { self: { refName: 'refs/heads/main' } } },
variables: {
TARGET_ENV: { value: 'staging', isSecret: false },
},
}),
}
)
}
return { status: 200, body: 'Test trigger sent' }
},
})Bug notification workflow
Automatically notify developers when a bug is assigned to them:
- Service Hooks → New → Web Hooks
- Event: Work item updated
- Filter: Work item type = Bug, Field changed = Assigned To
- Webhook URL: your notification service
The notification service sends a Teams/Slack DM to the newly assigned developer with the bug title, priority, and a direct link.
Common errors and fixes
Error: Service hook fires but Teams notification doesn't appear
Fix: Test the webhook URL independently with curl -X POST [url] -d '{"text":"test"}'. If this works, the issue is in the Azure DevOps configuration. If not, the Teams webhook may have expired — regenerate it.
Error: Custom webhook sends but the external system doesn't trigger Fix: The external system must return HTTP 200–299 within 60 seconds. If it returns an error or times out, Azure DevOps marks the hook as failed and may disable it after repeated failures. Check the hook's History tab in Service Hooks settings.
Error: Service hook triggers for all builds, not just the regression pipeline Fix: Add a filter: Pipeline name = [exact pipeline name]. Without filters, the hook fires for every build in the project.
Error: Service hook history shows "Exceeded retry limit — hook disabled" Fix: Re-enable the hook in Service Hooks → [Hook] → Enable. Fix the receiving endpoint so it responds quickly, then re-enable.
Stay ahead in AI-driven QA
Get practical tutorials on test automation, AI testing, and quality engineering — straight to your inbox. No spam, unsubscribe any time.
Discussion
Sign in with GitHub to comment · powered by Giscus