Example Workflow: Azure DevOps Webhook-Driven Documentation & Work Item
This workflow demonstrates how to automatically generate code documentation, UML diagrams, and test strategies on every push to the main branch of an Azure DevOps repository. Results are aggregated into a rich report, committed back to the repo, a work item is created, and the team is notified via Slack and email .
flowchart TD
A[π Azure DevOps Webhook] --> B[π§Ή Filter: Main Branch Push]
B --> C[π Extract Repository Info]
C --> D[π List Repository Files]
D --> E[π Filter Code Files]
E --> F[π₯ Get File Content]
F --> G[π οΈ Prepare Source Code]
G --> H[π§ Generate Documentation]
G --> I[π Generate UML Diagrams]
G --> J[π§ͺ Generate Test Strategies]
H & I & J --> K[π§© Aggregate & Format Results]
K --> L[π Create Work Item]
L --> M[β
Commit Documentation]
M --> N[π£ Notify Team (Slack & Email)]
N --> O[π Webhook Response]
Workflow Overview
- Trigger: Azure DevOps webhook on every push.
- Filter: Only main branch events.
- File Discovery: List all files; filter to code extensions.
- Content Prep: Download file content; wrap for AI.
- Generation:
- Code Documentation
- UML Diagrams
- Test Strategies
- Aggregation: Combine all outputs into a single report.
- Reporting:
- Create Azure DevOps work item
- Commit documentation files (
/docs/β¦) - Notify via Slack & Email
- Response: Return JSON status to webhook source.
1. Trigger: Azure DevOps Webhook π
Captures incoming HTTP POSTs from Azure DevOps service hooks.
{
"id": "azure-webhook-trigger",
"name": "Azure DevOps Webhook",
"type": "n8n-nodes-base.webhook",
"parameters": {
"httpMethod": "POST",
"path": "azure-devops-webhook",
"responseMode": "responseNode"
}
}
This node listens for events at /webhook/azure-devops-webhook .
2. Filter: Main Branch Push π§Ή
Ensures only pushes to refs/heads/main proceed.
{
"id": "filter-main-push",
"type": "n8n-nodes-base.if",
"parameters": {
"conditions": {
"conditions": [
{
"leftValue": "={{ $json.eventType }}",
"rightValue": "git.push"
},
{
"leftValue": "={{ $json.resource.refUpdates[0].name }}",
"rightValue": "refs/heads/main"
}
],
"combinator": "and"
}
}
}
Non-main pushes trigger an instant βignoredβ response .
3. Extract Repository Info π
Parses organization, project, repository ID/name, and commit metadata.
// Extract organization, project, and repository info from webhook
const resource = $json.resource;
const repo = resource.repository;
const commits = resource.commits || [];
return {
json: {
organization: repo.remoteUrl.match(/https:\/\/dev\.azure\.com\/(.*?)\//)[1],
project: repo.project.name,
repositoryId: repo.id,
repositoryName: repo.name,
commits: commits.map(c => ({
commitId: c.commitId,
comment: c.comment,
author: c.author.name
}))
}
};
This code node standardizes context for downstream steps .
4. List & Filter Code Files π
- List Repository Files
- Node:
n8n-nodes-base.azureDevOps - Operation:
getRepositoryContent(recursive)
- Node:
- Filter Code Files
- Node:
n8n-nodes-base.code - Filters
.js,.ts,.py, etc. - Limits to 10 files for performance .
- Node:
5. Get & Prepare Source Code π οΈ
- Get File Content
- Downloads raw file blob.
- Prepare Source Code
- Wraps content, file name, path, language, and latest commit in JSON for AI.
// Prepare source code for DocuWriter.ai
const fileContent = $json.content || $json.body;
const latestCommit = ($json.commits || [])[0] || {};
return {
json: {
sourceCode: fileContent,
fileName: $json.fileName,
filePath: $json.filePath,
language: $json.extension.replace('.', ''),
repository: {
organization: $json.organization,
project: $json.project,
name: $json.repositoryName,
latestCommit
}
}
};
This ensures DocuWriter.ai nodes receive a uniform payload .
6. Generate Documentation, UML Diagrams & Test Strategies π§
Three parallel DocuWriter.ai action nodes:
| Node ID | Generation Type | Mode | Purpose |
|---|---|---|---|
| generate-documentation | Documentation | accurate | Full code docs: purpose, dependencies, examples, improvements |
| generate-diagrams | UML Diagrams | fast | Class/data-flow diagrams for architecture |
| generate-tests | Tests | fast | Unit/integration/pipeline test recommendations |
Each node uses sourceCode from the previous step .
7. Aggregate & Format Results π§©
- Aggregate Results: Combines all AI outputs into one item list.
- Format Documentation: Builds a Markdown report and work item description.
// Create comprehensive documentation report
const items = $input.all();
let doc = '', dia = '', tst = '';
for (const it of items) {
const gen = it.json.generatedContent;
if (gen.includes('mermaid') || gen.includes('UML')) {
dia += `\n### Diagrams for \`${it.json.fileName}\`\n\n${gen}\n\n---\n`;
} else if (/test/i.test(gen)) {
tst += `\n### Test Strategy for \`${it.json.fileName}\`\n\n${gen}\n\n---\n`;
} else {
doc += `\n### Documentation for \`${it.json.fileName}\`\n\n${gen}\n\n---\n`;
}
}
// Build work item content...
This snippet shows splitting by content type for sections .
8. Create Azure DevOps Work Item π
Automatically creates a User Story titled:
π Documentation Update - {repositoryName} ({YYYY-MM-DD})
Description includes the aggregated Markdown report and tags: documentation;automated;docuwriter-ai .
9. Commit Documentation to Repo β
Commits three Markdown files to /docs:
automated-documentation.mdarchitecture-diagrams.mdtesting-strategies.md
Each fileβs content is injected from the aggregated JSON fields .
10. Notify Team via Slack & Email π£
- Slack
- Channel:
#devops - Message: π Azure DevOps Documentation Generated
- Fields: Files analyzed, work item created, report sections
- Channel:
- Email
- To: Latest commit author
- Subject: π Azure DevOps Documentation Generated β {repoName}
- Body: Summary of generated content and next steps .
11. Webhook Response π
Sends a JSON payload back to the caller with:
{
"status": "success",
"message": "Documentation generated successfully",
"workItemId": "...",
"filesAnalyzed": 8
}
This confirms completion to Azure DevOps.
Adaptation Tips:
- Change branch filters to target release or feature branches.
- Adjust code file limits and extensions for your repo.
- Customize additionalInstructions in DocuWriter.ai nodes.
- Extend notifications to other channels (Teams, Email groups).
This example can be cloned and tailored to fit any Azure DevOps CI/CD pipeline.
Updated