daxu
daxu

Reputation: 4084

Build.Reason showing IndividualCI other than PullRequest in azure devop

I am trying to run different build steps when someone clicked enqueue button or when triggered by a PR merge. My yaml is fairly simple at the moment:

trigger:
- master
- R_Current_Sprint

pool:
  name: Azure Pipelines
  vmImage: 'windows-latest'
  demands:....

However, when I trigger it via a PR merge, we can see it showing reason as Individual CI. enter image description here

For Build.Reason, the document says:

PullRequest: The build was triggered by a Git branch policy that requires a build.

So looks like my understanding is different here. I thought if I create a PR request and approve it, the build will be triggered with reason "PullRequest". Clearly my thought is wrong. So what is "The build was triggered by a Git branch policy that requires a build"?

enter image description here

Upvotes: 2

Views: 3868

Answers (2)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31083

It seems there is a misunderstanding about PR triggers. Pull request (PR) triggers cause a pipeline to run whenever a pull request is opened with one of the specified target branches, or when changes are pushed to such a pull request.

In Azure Repos Git, this functionality is implemented using branch policies. To enable pull request validation in Azure Git Repos, navigate to the branch policies for the desired branch, and configure the Build validation policy (Validate code by pre-merging and building pull request changes) for that branch.

Upvotes: 1

Daniel Mann
Daniel Mann

Reputation: 59037

That build wasn't for a pull request, it was for the merge that happened when the PR was completed. There's a difference; pull requests can require (via branch policy) builds to happen before they can be merged. That's the situation where you'll see the reason as Pull Request.

Upvotes: 3

Related Questions