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 πŸ“‚

  1. List Repository Files
    • Node: n8n-nodes-base.azureDevOps
    • Operation: getRepositoryContent (recursive)
  2. Filter Code Files
    • Node: n8n-nodes-base.code
    • Filters .js, .ts, .py, etc.
    • Limits to 10 files for performance .

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.md
  • architecture-diagrams.md
  • testing-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
  • 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.