0

Which branch does the build pipeline runs on a PR? I mean, you can set a build pipeline to run during a PR, but the docs doesn't clarify from which branch version does this pipeline will run. My teams doesn't use gitflow, so for sure it isn't the "default branch" settings (because my build pipeline doesn't even exists on the default branch of the repository (main). On the following image it's my current build policy settings:

build settings for branch D

supose my fraudchecker-build exists on branches A,B and C. Each branch has a differen't "version/code" of this pipeline. How can i know, when i set a build policy, which branch the fraudchecker-build will execute during a PR: A,B or C? I can't assume it will be the current branch where i'm setting de build policy (supose it is branch D)

doc page: azure pipelines doc page

victor israe
  • 415
  • 3
  • 14
  • 1
    Does this answer your question? [Does pull request in Azure devops merge the code and then runs the build definition](https://stackoverflow.com/questions/56310212/does-pull-request-in-azure-devops-merge-the-code-and-then-runs-the-build-definit) – Vince Bowdren Aug 13 '22 at 15:35
  • At first glance, I couldn't make the connection between my question and this one. But after the discussion below, I can clearly see they are related – victor israe Sep 03 '22 at 16:55

1 Answers1

0

The pipeline will build and validate the code from the source branch i.e. if you create a PR to merge branch B into main, it will build on branch B code

Edit - AS Vince stated I've simplified it too much in my post. It runs on the combined code of the source and target branch i.e. what the target branch will look like post PR completion

DavidCox88
  • 813
  • 1
  • 10
  • hi!Thank tou for your answer! Is it possible to test your statement without doing a POC? I mean, is there some documentation page that state this behavior? – victor israe Aug 12 '22 at 13:51
  • 1
    By definition of it being a Build Validation this must be how it works. This step is designed to check that any new code being pulled into the branch is working, therefore it must be building and validating the source branch. I'm not sure if its officially stated anywhere but it's implied by the nature of what the task does – DavidCox88 Aug 12 '22 at 13:59
  • 1
    There's some more information on the [PR Trigger](https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#pr-triggers) documentation. First bullet states "The pipelines specified by the target branch's build validation policy will run on the merge commit (the merged code between the source and target branches of the pull request" i.e. Build validation runs on the last commited code to the source branch of the PR – DavidCox88 Aug 12 '22 at 14:08
  • 2
    Note that the comment "build validation policy will run on the merge commit (the merged code between the source and target branches of the pull request)" Means that if you use YAML pipelines, and there are non conflicting changes in the YAML, then the build that runs will be defined by the merged YAML file – James Reed Aug 12 '22 at 15:24
  • 1
    @DavidCox88 no, the PR build does not run on the source branch. It runs on the special 'merge branch', created with a merge from the source branch into the target branch - i.e. the same as the target branch would be after completing the pull request. – Vince Bowdren Aug 13 '22 at 15:29
  • 1
    Thanks Vince, this is what I meant but was dumbing it down. You've explained it a lot more eloquently so I'll update my post to reflect this – DavidCox88 Aug 13 '22 at 17:07