9

I created a Pull Request which triggers the build and the build was successful, but after some time my build status changed to "build expired" so to finish the pull request I need to trigger it one more time. So the question is: Why has this happened and how do I avoid an expired build?

Sergey
  • 1,608
  • 1
  • 27
  • 40
Roman Borovets
  • 818
  • 12
  • 25

2 Answers2

18

"Build Expired" is a feature of branch policies. Set a build expiration to make sure that updates to your protected branch don't break changes in open pull requests.

Always require a new build

This option sets the build policy status in a pull request to "failed" when the protected branch is updated. You must re-queue 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.


Require a new build if older than ... hours

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.


Don't require a new build

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.


More details on "Branch Policies"

Sergey
  • 1,608
  • 1
  • 27
  • 40
Roman Borovets
  • 818
  • 12
  • 25
  • Good explanation! I recommend starting with the less strict option "Require a new build if older than ... hours". In case the development team over time see pull request often breaks because of changes in the protected branch, then they can go for a more strict option "Always require a new build". – Jagjit Singh Feb 26 '20 at 09:52
5

On the overview of the push request, next to "Build Expired" - click on the ellipses (3 dots to the right) and select "Queue Build". If it fails, pull master, merge it into your branch and re-push.

Will
  • 367
  • 3
  • 4
  • 2
    is there any way to automate this? if there are 4-5 pull requests, then its a hussle to click on every one of them.. – Küzdi Máté Jan 29 '20 at 11:31
  • I'm wondering the same thing, very tedious to do this manually for 5+ concurrent pull requests – Wouter Roos Apr 29 '20 at 14:02
  • Per [Auto-complete does not retrigger expired build](https://developercommunity.visualstudio.com/content/problem/560891/auto-complete-does-not-retrigger-expired-build.html) this is a deliberate feature. – Jiří Baum Dec 17 '20 at 00:47
  • Presumably one could write a script that periodically checks all the pull requests via the API, and if no build is in progress and there are expired builds, re-queues one of the expired builds (oldest, or newest, or by priority, or at random). – Jiří Baum Dec 17 '20 at 00:58