Search code examples
azure-devopsazure-pipelines

Azure Devops restart expired build validation


Assume a repository with two PRs on it (!1 and !2)

/main is protected by policy and requires build validation This build validation exires, once main has changed Build validation gets triggered on each new commit in the /feature branch

BUT Build validation does not restart itself, once it expired through changes in main.

So for all PRs had good build validaiton before a change in /main, have to be triggered again.

Is there a way to automatically trigger the build-validation of the other PRs?

Screenshot of current build validation config


Solution

  • This is by design. According to this ticket,

    The expired builds will be requeued automatically when the ONLY policy keeping the PR from completing is an expired build.

    When we implemented this feature we wanted to make sure that it didn’t create a chain reaction of builds getting re-queued so we intentionally only attempt one auto re-queue for now. If after autocomplete tries to requeue a build and it expires again (for example you have a build policy with immediate expiration when the target branch is updated), then auto complete won’t attempt to re-queue the build a second time.

    To help you understand, you can refer to the following example. I have three PRs, merged from Branch1, Branch2, and Branch3 to main. Every PR has Auto-complete enabled.

    enter image description here

    1. PR3 triggered the validation pipeline
    2. PR2 triggered the validation pipeline
    3. PR1 triggered the validation pipeline
    4. Because PR3 has been completed and Branch3 has been merged into the main branch, PR build policy status of PR2 was set to failed. The system tried to create a new merge commit and requeue the build automatically.
    5. Similarly, PR build policy status of PR1 was set to failed. The system tried to create a new merge commit and requeue the build automatically.
    6. PR2 completed and Branch2 merged into main branch. Then the PR build policy status of PR1 is failed again. At this time, even if Auto-completed is enabled, no new build will be automatically requeued.

    enter image description here

    To automatically trigger the build-validation of the other PRs, you can enable Auto-completed of your PR. But as mentioned above, if the build policy status of a PR becomes failed again, it will not be automatically queued.

    As mentioned in doc Build validation,

    Immediately when branch name is updated: This option is best for teams whose important branches have few changes. Teams working in busy development branches might find it disruptive to wait for a build every time the branch updates.

    If there are many changes in your branches, it's suggested to use After <n> hours if <branch name> has been updated option.