I have two build pipelines on Azure DevOps. Let's call the pipelines as Pipeline A and Pipeline B.
Both pipelines' default branches are set to "Development" branch in Get Sources section.
Pipeline A enables the continuous integration and has the branch filters for two branches:
So Pipeline A is being triggered once the code is merged to Development OR Test branch.
Pipeline B trigger is set to Build Completion of Pipeline A, and branch filters are added to both Development and Test, as well.
Pipeline B is triggered when Pipeline A is completed for Development or Test branch merges, HOWEVER, when Pipeline A is triggered by Test branch and completed, Pipeline B pulls the code base from Development branch (since it is set as default branch), regardless of which branch Pipeline A is triggered by. Pipeline A simply gets it's sources from the triggering branch, however Pipeline B is simply going with the default branch.
How can I make my Pipeline B to use it's code base as the same as triggering pipeline's (Pipeline A) code base?
Hint: I am using classic editor in my pipelines workflow.
Since you are using Build Completion trigger, the triggered pipeline will use the version of the code in the branch specified by the Default branch for manual and scheduled builds setting
.
I am afraid that there is no out-of-box support to make two pipelines to use the same branch to run the pipeline.
For a workaround, you can add a task(Trigger Azure DevOps Pipeline from extension from Extension Trigger Azure DevOps Pipeline) to Pipeline A to trigger Pipeline B and remove the Build Completion in Pipeline B.
Then you can set the branch to run the Pipeline B.And you can set the condition to run the task in Pipeline A.
For example:
When the pipeline A is running on Development or test branch, the task will run and pass the branch value $(Build.SourceBranch)
to pipeline B.
Refer to this doc about Condition.