Azure Boards

Azure DevOps Marketplace extension.

BranchDeploy / Guides / Azure Pipelines Manual Run Wrong Branch

Why Azure Pipelines manual runs deploy the wrong branch

A manual Azure Pipeline run can deploy the wrong branch for simple reasons: the default branch was left selected, a similar branch name was chosen from autocomplete, a PR target branch was copied instead of the source branch, or the pipeline YAML ignores the selected branch in a later step.

The fix is to make the selected source branch visible and reduce the number of places where a user has to type or copy it.

Most common causes

The default branch was selected

The Run pipeline dialog often opens with the pipeline's default branch selected. If the user does not change it, the run may deploy main or develop instead of the feature branch.

The branch name was copied manually

Long ticket branch names are easy to mistype or choose incorrectly from autocomplete. Similar names such as feature/1234-checkout and feature/1234-checkout-fix are a common source of wrong-branch runs.

The PR target branch was used

For a PR from feature/checkout-flow into main, the branch to test before merge is usually the source branch. Copying the target branch deploys the shared branch instead.

The YAML checks out a different ref

Most pipelines check out the selected source branch by default. But custom checkout logic, scripts, or deployment templates can override that behavior. If the run claims to use one branch but deploys another, inspect the checkout and deployment steps.

Branch filters or conditions skip deployment stages

The run may start on the right branch, but a deployment stage may be skipped because a YAML condition only allows main or release/*. This can make users rerun the pipeline on a different branch until something deploys.

How to diagnose it

Add an early diagnostic step to print the branch Azure Pipelines thinks it is running on:

steps:
  - script: |
      echo "Build.SourceBranch=$(Build.SourceBranch)"
      echo "Build.SourceBranchName=$(Build.SourceBranchName)"
    displayName: Print selected branch

Then check the run summary and logs:

Manual fix

  1. Open the work item or PR that contains the change.
  2. Copy the exact source branch, including the correct prefix such as feature/ or bugfix/.
  3. Open the deployment pipeline.
  4. Click Run pipeline.
  5. Replace the default branch with the source branch you copied.
  6. Confirm any variables or parameters.
  7. Queue the run and verify Build.SourceBranch in the logs.

BranchDeploy fix

BranchDeploy reduces wrong-branch runs by removing the manual branch-copy step. It reads the linked branch or PR source branch from the Azure Boards work item and shows it in a confirmation step before queueing the pipeline.

This does not replace good pipeline design. The pipeline still needs to deploy the selected source branch. But it prevents the most common input error: a person choosing the wrong branch in the Run pipeline dialog.

Prevention checklist

Official Azure DevOps references

No clipboard. No tab switching. No branch-name guesswork.

BranchDeploy adds a deploy action to Azure Boards work items. Free for one project and one environment.

Install Free forever for one project.

Ready to deploy?

Install BranchDeploy from the Marketplace, open Project Settings, add your pipeline ID, and deploy from a work item in minutes.

$ az devops extension install --extension-id branchdeploy --publisher-id PixelFunnelLtd
Install free
Requirements
  • Azure Repos + Azure Pipelines.
  • Permission to queue the pipeline.
  • No BranchDeploy account needed (Free).
Setup
  • Install the extension.
  • Open Project Settings → BranchDeploy.
  • Enter your pipeline ID and save.
Free tier
  • One project, one environment.
  • Queues as your Azure DevOps session.
  • Completely free, forever.
Pro
BranchDeploy // © 2026 Pixel Funnel Ltd // Azure DevOps Marketplace extension // No clipboard. No tab switching. No branch-name guesswork.