Add Azure DevOps work item support to Build Failure service #6361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR expands the Build Failure service (
DotNet.Status.Web.Controllers.AzurePipelinesController) to create work items in Azure DevOps (Azure Boards) in addition to GitHub issues. The Engineering Services team has moved all issue management to Azure DevOps, so this service now supports both platforms through configuration.Changes
1. Extended Azure DevOps Client (
src/Telemetry/AzureDevOpsClient/)Added three new methods to
IAzureDevOpsClientinterface and implemented them inAzureDevOpsClient:CreateBuildFailureWorkItem: Creates a new Azure DevOps work item with customizable title, description, assignee, area path, and tagsUpdateWorkItemComment: Adds comments to existing work items for tracking multiple failuresQueryWorkItemsByTitle: Queries for existing work items by title prefix to support "update existing" functionalityThe implementation uses the Azure DevOps REST API v6.0 and v7.1-preview for work item creation and commenting.
2. Updated Configuration (
src/DotNet.Status.Web/DotNet.Status.Web/Options/BuildMonitorOptions.cs)Extended
BuildMonitorOptions.IssuesOptionswith new properties:UseAzureDevOps: Boolean flag to enable Azure DevOps work item creationAzureDevOpsProject: Target Azure DevOps project nameAzureDevOpsAreaPath: Area path for organizing work items3. Refactored Controller (
src/DotNet.Status.Web/DotNet.Status.Web/Controllers/AzurePipelinesController.cs)Refactored
ProcessBuildNotificationsAsyncto support both GitHub and Azure DevOps:CreateGitHubIssueAsync: Extracted existing GitHub issue creation logic (no functional changes)CreateAzureDevOpsWorkItemAsync: New method for Azure DevOps work item creation with HTML-formatted descriptionsUseAzureDevOpsconfiguration flag4. Added Tests (
src/DotNet.Status.Web/DotNet.Status.Web.Tests/AzurePipelinesControllerTests.cs)BuildCompleteCreateAzureDevOpsWorkItemtest to verify work item creationConfiguration Example
To configure builds to create Azure DevOps work items:
{ "Monitor": { "Organization": "dnceng", "Builds": [ { "Project": "internal", "DefinitionPath": "\\dotnet\\runtime\\official", "Branches": ["main", "release/*"], "Assignee": "[email protected]", "IssuesId": "runtime-failures" } ] }, "Issues": [ { "Id": "runtime-failures", "UseAzureDevOps": true, "AzureDevOpsProject": "internal", "AzureDevOpsAreaPath": "internal\\Dotnet-Core-Engineering", "Labels": ["build-failure", "automated"], "UpdateExisting": true } ] }Key Features
✅ Backward Compatible: Existing GitHub issue creation continues to work unchanged
✅ Configuration-Driven: Teams can choose GitHub or Azure DevOps per build/repository
✅ Feature Parity: Supports "update existing" functionality for both platforms
✅ Rich Formatting: HTML formatting for Azure DevOps, Markdown for GitHub
✅ Security: CodeQL scan passed with 0 vulnerabilities
✅ Code Standards: Uses explicit types throughout (no
var)Testing
Fixes #[issue-number]
Original prompt
Fixes #6360
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.