microsoft / azuredevopslabs

Learn how you can plan smartly, collaborate better, and ship faster with a set of modern development services with Azure DevOps.
https://www.azuredevopslabs.com
MIT License
832 stars 928 forks source link

Azure devops pipeline multi-stage-pull-request-triggered-builds merging in commits made to master after build started #648

Open moodya opened 1 year ago

moodya commented 1 year ago

We use an Azure Devops for our repository (git) and ci/cd. We employ a trunk based development strategy and main branch which enforce all changes to be merged in via pull requests (PRs). Upon a merge to main the various relevant pipelines are triggered.

Recently a PR (A) triggered pipeline had made its way through our stages (environments) - BUILD, DEV, QA - and was ready to be deployed to UAT. Then, another PR (B) was completed and merged to main, which contained a breaking change to a build template which was used by the previous pipeline triggered by PR (A). Then, the pipeline related to PR (A) was deployed to UAT and failed as it appeared to pull in the breaking change from PR (B).

"The problem is that for each stage in our pipeline, we do a checkout using Azure DevOps' built-in checkout action. If someone merges to main while a build is on-going. different stages of the build will use different merge commits."

The above quote is taken from the following post which appears to describe this behavior - https://andrewlock.net/handling-concurrent-merges-to-master-in-multi-stage-azure-devops-pipelines/.

Can you confirm whether this is a behavior of azure devops pipelines and azure git repos? As the implications could potentially effect our production deployments.

Added issue here