Azure DevOps CI/CD 管道:失败时恢复提交

发布于 2025-01-18 02:13:56 字数 141 浏览 4 评论 0原文

我目前正在构建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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卖梦商人 2025-01-25 02:13:56

通常,您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文