Azure DevOps CI/CD 管道:失败时恢复提交
我目前正在构建Azure DevOps CI/CD管道,如果失败,我不想保留导致存储库中失败的代码。因此,如果管道失败,我希望在该提交之前将存储库恢复到最后一个版本。我找不到任何帮助。此选项如何看起来,如何将此选项添加到我的.YAML文件中?
太感谢了。
I am currently building an Azure DevOps CI/CD pipeline and if it fails, I don't want to keep the code that lead to the fail in my repository. So, if the pipeline fails, I want the repo to be reverted to the last version before that commit. I can't find any help on that. How does this option look like and how can I add this option to my .yaml file?
Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您可以使用
git revert
命令来恢复某些现有提交。在管道中,您可以查看 git 存储库和进行更改的分支。然后运行
git revert
命令来“撤消”一些提交。更多详细信息,您可以参考以下文章:
不过,正如@GeralexGR所建议的,建议您最好基于默认分支(main/master)创建一个develop分支,并在此分支上进行更改。然后在开发分支上构建并测试代码。一旦开发分支上的一切都很好,您可以创建一个拉取请求以将更改从开发分支合并到默认分支。
Normally, you can use the
git revert
command to revert some existing commits.In your pipeline, you can check out the git repository and the branch where you made the changes. Then run the
git revert
command to 'undo' some commits.For more details, you can reference the following articles:
However, as @GeralexGR has suggested, it is recommended that you'd better create a develop branch based on the default branch (main/master) and make changes on this branch. Then build and test the code on the develop branch. Once everything is good on the develop branch, you can create a Pull Request to merge the changes from the develop branch to the default branch.