2
votes

I had this working up till last week, but now it's not. I have a build policy on my develop branch. It executes a build definition automatically when a pull request is created. The build runs on a hosted agent.

It was working, but now I need to manually trigger the build when I create a PR. I tried enabling then disabling. Also tried deleting and re-creating the policy. Neither worked.

Am I missing something? Has something changed in VSTS?

Screenshot of build policy: enter image description here

1
What's the scenario when you found the build not triggered? Did you create a create PR to merge into develop branch or did you just a a comment (or else) for an existing PR?Marina Liu
Is your repo hosted in VSTS or somewhere else?Brian Cristante
@Marina - Same process when it worked, and when it didn't. Before, creating a new PR to merge into develop and pushing a new commit to an existing PR triggered the build. Now neither trigger the build.nthpixel
@Brian - Repo is hosted in VSTS.nthpixel
@nthpixel Can you share the screen shot for how the build validation policy you configured?Marina Liu

1 Answers

1
votes

For the PR build validation does not triggered immediately after pushing changes to the source branch, is caused by the Build expiration set with After 12 hours if develop has been uploaded.

That means, build will not be triggered immediately when source branch update. More details about build expiration as below:

Set a build expiration to make sure that updates to your protected branch don't break changes in open pull requests.

  • Immediately when branch name is updated: This option sets the build policy status in a pull request to failed when the protected branch is updated. You must requeue a build to refresh the build status. This setting ensures that the changes in pull requests build successfully even as the protected branch changes. This option is best for teams that have important branches with a lower volume of changes. Teams working in busy development branches may find it disruptive to wait for a build to complete every time the protected branch is updated.

  • After n hours if branch name has been updated: This option expires the current policy status when the protected branch updates if the passing build is older than the threshold entered. This option is a compromise between always requiring a build when the protected branch updates and never requiring one. This choice is excellent for reducing the number of builds when your protected branch has frequent updates.

  • Never: Updates to the protected branch do not change the policy status. This reduces the number of builds for your branch, but can cause problems when closing pull requests that haven't been updated recently.

So if you want the build triggered immediately after PR updated, you should change the Build expiration as Immediately when develop is updated.

enter image description here