并行管道构建导致 git 冲突
Parallel pipeline builds causing git collisions
我在 Azure devops 中设置了一个构建管道,每次 PR 进入主分支时都会运行。
步骤如下:
checkout main
install dependencies
npm version to increment
Build
Publish to npm feed
Deploy to a test/staging environment
Push the change to the version number back to git.
由于每次 PR 完成时都会运行构建,因此偶尔会出现并行构建。根据哪个先完成,推送将失败,因为它是“脏的”。
我在寻找绕过它的方法时遇到问题。
可能的方法:
- 当git推送命令失败时,只抑制失败(不理想)。
- 强制 git 推送(不理想)。
- 如果构建排队而另一个正在排队 运行,请等待它完成后再开始新构建
- 取消旧版本和批处理?
- 以某种方式重构构建过程。
我遗漏了什么吗?
我不确定这是否能回答你的问题,因为你没有分享你的管道定义(所以如果可以的话请这样做)但也许 Batching CI runs 可以帮助你
If you have many team members uploading changes often, you may want to reduce the number of runs you start. If you set batch to true, when a pipeline is running, the system waits until the run is completed, then starts another run with all changes that have not yet been built.
这样你就不会得到并发构建,所以如果分组构建对你来说是可以接受的,这似乎是适合你的解决方案。
我在 Azure devops 中设置了一个构建管道,每次 PR 进入主分支时都会运行。
步骤如下:
checkout main
install dependencies
npm version to increment
Build
Publish to npm feed
Deploy to a test/staging environment
Push the change to the version number back to git.
由于每次 PR 完成时都会运行构建,因此偶尔会出现并行构建。根据哪个先完成,推送将失败,因为它是“脏的”。
我在寻找绕过它的方法时遇到问题。
可能的方法:
- 当git推送命令失败时,只抑制失败(不理想)。
- 强制 git 推送(不理想)。
- 如果构建排队而另一个正在排队 运行,请等待它完成后再开始新构建
- 取消旧版本和批处理?
- 以某种方式重构构建过程。
我遗漏了什么吗?
我不确定这是否能回答你的问题,因为你没有分享你的管道定义(所以如果可以的话请这样做)但也许 Batching CI runs 可以帮助你
If you have many team members uploading changes often, you may want to reduce the number of runs you start. If you set batch to true, when a pipeline is running, the system waits until the run is completed, then starts another run with all changes that have not yet been built.
这样你就不会得到并发构建,所以如果分组构建对你来说是可以接受的,这似乎是适合你的解决方案。