[英]Revert Azure Devops Repo to unmerged state if Pipeline Unit Tests fail
We have an Azure Pipeline that merges into a repository that converts.json files representing customer orders into C# objects.我们有一个 Azure 管道,它合并到一个存储库中,该存储库将代表客户订单的 json 文件转换为 C# 对象。 Naturally, if the design or naming of these C# objects ever changes, the old orders will become unusable, so we run a script 'Migrating' all these outdated.jsons to conform to the new model.当然,如果这些 C# 对象的设计或命名发生变化,旧订单将无法使用,因此我们运行脚本“迁移”所有这些过时的.json 以符合新的 model。
Our current pipeline that merges dev into production Migrates our.jsons, and we run a PowerShell unit test script after the pipeline's completion to ensure that the.jsons have successfully Migrated.我们当前将 dev 合并到生产中的管道迁移 our.jsons,我们在管道完成后运行 PowerShell 单元测试脚本以确保.jsons 已成功迁移。 We'd like to place this test into the pipeline itself, but there are two conditions we'd prefer to meet.我们希望将此测试放入管道本身,但我们希望满足两个条件。
If the Test fails, not only abort the merge, but revert the.jsons to their un-Migrated versions.如果测试失败,不仅要中止合并,还要将 .jsons 恢复为其未迁移的版本。
Give us the option to continue the merge anyway, in the event that the website encounters an error so critical and urgent we are willing to bear the loss of a few quotes.让我们选择继续合并,如果网站遇到如此严重和紧急的错误,我们愿意承担一些报价的损失。
Are these conditions feasible?这些条件是否可行?
According to your description, you may consider using Build validation as the Branch policies and settings .根据您的描述,您可以考虑使用构建验证作为分支策略和设置。
Basically, let's assume your production code is in the Production
branch;基本上,假设您的生产代码在Production
分支中; then you can create a Dev
branch and push your new commits into the Dev
branch.然后你可以创建一个Dev
分支并将你的新提交推送到Dev
分支。 When setting the Build validation policy on the Production
branch, the PR request will not be completed if the build fails, which contains the unit test.在Production
分支上设置 Build 验证策略时,如果构建失败,PR 请求将不会完成,其中包含单元测试。 Therefore the new code from Dev
branch will not be merged into the Production
branch.因此,来自Dev
分支的新代码不会合并到Production
分支中。
In the meanwhile, other branch policies may also help you with the code version control.同时,其他分支策略也可以帮助您进行代码版本控制。 Hope the following documents can help as well.希望以下文档也能有所帮助。
Require a minimum number of reviewers 需要最少数量的审阅者
Check for linked work items 检查链接的工作项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.