[Azure Pipelines] Implement Copilot build detection with x64-linux first execution
Problem
Copilot-triggered workflows were overloading the Azure Pipelines pool by running all triplets in parallel, causing resource contention and slower feedback for both Copilot and regular users.
Solution
This PR implements automatic Copilot build detection and conditional execution logic:
๐ Copilot Detection
Detects Copilot builds via multiple indicators:
-
Build.RequestedForEmailcontains "copilot" or "github.com" -
Build.SourceVersionMessagecontains "copilot" -
Build.RequestedForcontains "copilot"
๐ฏ Execution Strategy
For Copilot builds:
- Run x64-linux first
- Only run other triplets if x64-linux succeeds
- Cancel remaining jobs if x64-linux fails
For regular builds:
- Unchanged behavior - all triplets run in parallel
๐๏ธ Implementation
Restructured the pipeline into 3 stages:
stages:
- DetectBuildType # Determines if build is Copilot-triggered
- BuildX64Linux # Always runs x64-linux first
- BuildAllOthers # Conditionally runs other triplets
The key logic uses Azure Pipelines stage conditions:
condition: or(
eq(dependencies.DetectBuildType.outputs['DetectCopilot.detect.IsCopilotBuild'], 'false'),
succeeded('BuildX64Linux')
)
โ Benefits
- Resource Efficiency: Prevents pool overload for Copilot builds
- Fast Feedback: Early failure detection saves time and resources
- Zero Impact: Regular user workflows completely unchanged
- Robust Detection: Multiple fallback mechanisms catch various Copilot scenarios
๐งช Testing Scenarios
| Scenario | x64-linux | Other Jobs | Behavior |
|---|---|---|---|
| Copilot + Success | โ Runs first | โ Run after x64-linux | Serial execution |
| Copilot + Failure | โ Fails | โ Cancelled | Early termination |
| Regular Build | โ Runs | โ Run in parallel | Existing behavior |
Fixes #45945.
๐ก You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Let's use a two stage approach:
- A "scouting" stage. If the branch is not a copilot branch, this stage should do nothing and finish ASAP. If it is a copilot branch, this stage should build x64-linu...
Implemented the two-stage approach as requested. The pipeline now has:
- Scouting stage: Skips entirely for non-copilot builds, builds only x64-linux for copilot builds
- Full stage: Builds everything except x64-linux for copilot builds, or everything for regular builds
Commit: afab5b2
Plumb
dependsOnthrough the templates
Added dependsOn parameter to all template files (linux, windows, osx, android) and updated the main azure-pipelines.yml to pass the parameter instead of trying to add it at the template level. The templates now properly handle the dependsOn parameter and conditionally add it to the job definition when specified. Commit: aa5cd99
Since it seems like progress isn't getting made here and it's keeping a branch on github.com/microsoft alive I'm closing this. Please feel free to remake / reopen if you wish to continue.