简体   繁体   English

如果管道单元测试失败,则将 Azure Devops Repo 还原为未合并的 state

[英]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.我们希望将此测试放入管道本身,但我们希望满足两个条件。

  1. If the Test fails, not only abort the merge, but revert the.jsons to their un-Migrated versions.如果测试失败,不仅要中止合并,还要将 .jsons 恢复为其未迁移的版本。

  2. 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 检查链接的工作项

Check for comment resolution 检查评论解决方案

Limit merge types 限制合并类型

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure DevOps 管道中设置发布管道中的变量 - How to set Variables in Release pipeline in Azure DevOps pipeline Azure DevOps 管道 Json 变量替换 - Microsoft.Hosting.Lifetime - Azure DevOps Pipeline Json Variable Substitution - Microsoft.Hosting.Lifetime 从 json 文件导入 Azure Devops 管道变量 - import Azure Devops pipeline variables from json file Azure 管道:从存储库中的 json 文件中读取值并将其存储在管道变量中 - Azure Pipeline: Read values from json file in the repo and store it in pipeline variable 无法使用 RestApi 将文本文件添加到 Azure DevOps Repo - 包含“\”的文件 - Unable to Add Text File to Azure DevOps Repo using RestApi - File containing '\' DevOps 管道在将变量值发送为 JSON 时更改时间格式要部署的主体 Azure 资源与 Terraform - DevOps Pipeline changing Timeformat when sending variable values as JSON Body to Deploy Azure Resources with Terraform 如果我想在同一个 JSON 中为 Azure DevOps 管道使用 concat 和 encodeURI 应该是什么结构 - What should be the structure if I want to use concat and encodeURI in the same JSON for Azure DevOps pipeline 依赖于文件的.net核心asp.net单元测试 - appsettings.json - 在travis中失败 - .net core asp.net unit tests that depend on files - appsettings.json - fail in travis appsettings.json 和 appsettings.Release.json 文件在为.Netcore3.1 项目运行 Azure DevOps CI 管道后未合并 - appsetting.json and appsettings.Release.json files are not merging after ran the Azure DevOps CI pipeline for .Netcore3.1 project 与iOS单元测试的混淆 - Confusion with iOS Unit Tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM