This is a bit tricky to explain, but in Azure Pipelines if you have Build Validation policy for a Pull Request the build pipeline will run having the following variables:
System.PullRequest.SourceBranch
The branch that is being reviewed in a pull request. For example: refs/heads/feature/branch.
System.PullRequest.TargetBranch
The branch that is the target of a pull request. For example: refs/heads/master.
But after a Pull Request is completed and the CI triggers a pipeline build on the target branch (refs/head/master) it is no longer possible to view these variables.
I have a npm package where I want, after a successful PR merge, to publish either a new minor or patch version automatically based on if the PR branch starts with either refs/feature/ or refs/bugfix/ respectively.
How can I get the name of the source PR branch in this CI build on the target branch. (Not the PR build validation policy)