Automation

Azure DevOps: diagnose a pipeline completion trigger before rerunning promotion

A production runbook for separating trigger filters, default branch, executed YAML and pipeline resource metadata before rerunning or repairing an Azure DevOps promotion.

30 Oct 2026 azureazure-devopspipelinespipeline-resourcestriggersartifactsdevopsautomationobservabilityguardrailsrunbookrollbackproduction

A build pipeline completes successfully, but the production promotion either does not start or runs from an unexpected branch. The artifact exists and the deployment pipeline is healthy, so a manual run against the latest successful build looks like a quick recovery. It also bypasses the exact trigger contract that failed and may select a different run.

The running case uses app-ci to publish an artifact and app-promote to consume it through a pipeline resource. The repositories may be shared or separate. Before any production write, prove four identities: the source run, its branch and commit, the YAML version used by the promotion, and the artifact downloaded from the declared resource alias.

Freeze one missed or unexpected promotion

Capture immutable identifiers before editing YAML or queueing a run: source run ID, branch, commit, target pipeline ID, expected environment, UTC window, and the current value of Default branch for manual and scheduled builds.

incident: INC-ADO-20261030-01
source_pipeline: app-ci
source_run_id: 28741
source_branch: refs/heads/release/2026.10
source_commit: 9a7c4e2
target_pipeline: app-promote
expected_environment: prod-app
default_branch_setting: refs/heads/main
repositories:
  source: app-code
  target_yaml: platform-pipelines
writers_frozen:
  - manual_promotions
  - scheduled_promotions
decision_owner: platform-on-call

Do not replace the missed event with a manual run yet. A manually queued pipeline resource can select a latest successful run according to its selection rules. That is a different experiment from replaying the completion event.

Separate filter evaluation from the YAML that runs

A pipeline completion trigger makes two decisions. Azure DevOps first reads branch filters from the target pipeline version stored in its default branch setting. If the event matches, it chooses which YAML version to execute.

When source and target pipelines use the same repository, the target follows the branch and commit of the source event. With different repositories, the target uses the branch configured as Default branch for manual and scheduled builds. This explains incidents where a release branch appears eligible but the target executes main, or where a filter merged only into the release branch is never evaluated.

Treat the flow as four evidence layers:

  1. Event: source pipeline, run ID, result, branch, commit, stages and tags.
  2. Eligibility: target default branch setting and the resource filters stored there.
  3. Execution: source branch for a shared repository, target default branch for separate repositories.
  4. Consumption: pipeline resource alias, source run ID and downloaded artifact identity.

A successful source run proves only the first layer.

Read the contract from the evaluated branch

Inspect the target YAML in the branch named by the default branch setting. Verify the exact source, optional project, included and excluded branches, required stages, and tags. Pipeline completion triggers belong in the pipeline definition; declaring one only inside a YAML template does not activate it.

trigger: none
pr: none

resources:
  pipelines:
  - pipeline: app
    source: app-ci
    project: commerce
    trigger:
      branches:
        include:
        - refs/heads/release/*
        exclude:
        - refs/heads/release/old-*
      stages:
      - package
      tags:
      - promotable

Use one branch notation consistently. For cross-project resources, confirm that the default branch setting includes refs/heads/; an incomplete reference can prevent the trigger from firing.

Also rule out duplicate entry points. If the target keeps a CI trigger in addition to the pipeline completion trigger, one source change can create a CI run that consumes an older resource and a second run when app-ci completes.

Prove the resource at runtime

For YAML pipeline resources, runtime metadata belongs under resources.pipeline.<alias>.*. Classic Build.TriggeredBy.* variables do not describe this path. Log the resource run ID, branch and commit before download, then make the preflight fail closed if they do not match the promotion policy.

steps:
- bash: |
    set -euo pipefail
    printf 'reason=%s\n' "$BUILD_REASON"
    printf 'run_id=%s\n' "$RESOURCE_RUN_ID"
    printf 'branch=%s\n' "$RESOURCE_BRANCH"
    printf 'commit=%s\n' "$RESOURCE_COMMIT"
    test "$BUILD_REASON" = "ResourceTrigger"
    case "$RESOURCE_BRANCH" in
      refs/heads/release/*) ;;
      *) echo "Unexpected source branch" >&2; exit 20 ;;
    esac
    test -n "$RESOURCE_RUN_ID"
    test -n "$RESOURCE_COMMIT"
  env:
    RESOURCE_RUN_ID: $(resources.pipeline.app.runID)
    RESOURCE_BRANCH: $(resources.pipeline.app.sourceBranch)
    RESOURCE_COMMIT: $(resources.pipeline.app.sourceCommit)

- download: app
  artifact: drop

The alias in download: app must be the alias declared by pipeline: app, not the source pipeline display name. Preserve the preflight output with the deployment record.

Build a validation matrix

Reproduce the contract without touching production. Use a target stage that stops after preflight, then complete a source run for each relevant case.

cases:
- source_branch: refs/heads/release/2026.10
  source_stage: package
  source_tag: promotable
  expected_trigger: true
- source_branch: refs/heads/release/old-2025
  source_stage: package
  source_tag: promotable
  expected_trigger: false
- source_branch: refs/heads/main
  source_stage: package
  source_tag: promotable
  expected_trigger: false

For each case, keep the source run ID, target run ID or confirmed absence, target YAML branch, resource branch and commit, and downloaded artifact identity. A useful canary proves both positive and negative behavior. One expected run is not enough: a broad filter may trigger correctly while allowing unwanted branches.

Decide repair, hold or rollback

Promote the repair only when the evaluated branch contains the intended filters, the executed YAML branch is understood, runtime resource metadata matches the source event, and the artifact is tied to that run. Keep production frozen if any identity remains ambiguous.

If the incident followed a filter or default-branch change, rollback means restoring the previous YAML and pipeline setting together, then rerunning the matrix. Changing only one can leave eligibility and execution on different contracts.

A manual run is acceptable only as controlled recovery when the operator pins the exact pipeline resource run and the same preflight validates branch, commit and artifact. Never select “latest successful” to compensate for an unexplained trigger.

Conclusion

A pipeline completion incident is a disagreement between event, filter branch, executed YAML and consumed resource. The production decision is explicit: repair and promote after the matrix passes, restore the previous trigger contract, or hold. Rollback is complete only when an allowed source run triggers exactly one preflight, a denied run triggers none, and the promotion consumes the pinned source run.