TeamCity 和待处理的 Git 合并分支提交在测试失败的情况下保持构建

发布于 2024-08-27 13:12:28 字数 876 浏览 5 评论 0原文

我们使用 TeamCity 进行持续集成,使用 Git 进行源代码控制。一般来说,它工作得很好——方便、现代,并且在测试失败时我们可以快速得到反馈。

有一个与 Git 合并细节相关的奇怪行为。以下是该案例的步骤:

  1. 第一个开发人员从主存储库中提取。
  2. 第二个开发人员从主存储库中提取。
  3. 第一个开发人员在本地提交 A。
  4. 第二个开发人员在本地提交 B;
  5. 第二个开发人员推送提交 B。
  6. 第一个开发人员想要推送提交 A,但无法推送,因为他必须先拉取提交 B。
  7. 第一个开发人员从远程存储库中提取。
  8. 第一个开发人员推送提交 A 并生成合并分支提交。

主存储库中的提交历史如下:

  • B 第二个开发人员
  • A 第一个开发人员
  • 合并分支第一个开发人员。

现在,我们假设第二个开发人员在他的提交 B 中修复了一些失败的测试。TeamCity

将执行以下操作:

  1. 提交 B 到达 - TeamCity 生成构建 #1,所有测试均已通过
  2. 提交 A 到达 - TeamCity 生成构建 #2(没有提交) B) 测试栏变成红色!

  3. TeamCity 认为待处理的“合并分支”提交不包含任何更改(任何新文件) - 但它实际上包含提交 B 的合并,因此 TeamCity 不想在此处进行新构建并进行测试绿色。

这里有两个问题: 1. 在我们的例子中,我们在第二次提交(提交 A)中返回失败的测试 2. TeamCity 不想进行新的构建并使测试恢复绿色。

有谁知道如何解决这两个问题。

我考虑一些合理的一般方法。

We use TeamCity for continuous integration and Git for source control. Generally it works pretty well - convenient, modern and good us quick feedback when tests fails.

There is a strange behavior related to Git merge specifics. Here are steps of the case:

  1. First developer pulls from master repo.
  2. Second developer pulls from master repo.
  3. First developer makes commit A locally.
  4. Second developer makes commit B locally;
  5. Second developer pushes commit B.
  6. First developer want to push commit A but unable because he have to pull commit B first.
  7. First developer pull's from remote reposity.
  8. First developer pushes commit A and generated merge branch commit.

The history of commits in master repo is following:

  • B second developer
  • A first developer
  • merge branch first developer.

Now let's assume that Second Developer fixed some failing tests in his commit B.

What TeamCity will do is following:

  1. Commit B arrives - TeamCity makes build #1 with all tests passed
  2. Commit A arrives - TeamCity makes build #2 (without commit B) test bar becomes Red!

  3. TeamCity thought that Pending "Merge Branch" commit doesn't contain any changes (any new files) - but it actually does contain the merge of commit B, so the TeamCity don't want to make new build here and make tests green.

Here are two problems:
1. In our case we have failed tests returning back in second commit (commit A)
2. TeamCity don't want to make a new build and make tests back green.

Does anybody know how to fix both of this problems.

I consider some reasonable general approach.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

尐偏执 2024-09-03 13:12:28

只是补充一下,我强烈建议使用 git pull --rebase,或者完全只执行 git fetch,然后使用 git log -p ^master origin/master 修改已更改的内容,以确定我是否同意所发生的事情由于其他开发人员的工作。此时,我可以在远程更改的基础上重新调整我的工作,而 teamcity 不会给您提供您在此处看到的问题。这不是我围绕 teamcity 所做的事情,但也是工作流程的一部分,该工作流程允许更线性的历史记录和合并冲突解决方案,如果您要合并以前的合并,则无需重新访问。

HTH,

亚当

Just to add, I strongly advise on using git pull --rebase, or entirely just do a git fetch then do a revision of what has changed with git log -p ^master origin/master to determine if I'm ok with what happened due to other devs' work. At this point I can rebase my work on top of the remote changes and teamcity will not give you the problems you see here. This is not something I do to work around teamcity but is also part of a workflow that allows a more linear history and merge conflict resolutions that you do not have to revisit if you are merging previous merges.

HTH,

Adam

萌无敌 2024-09-03 13:12:28

5.0.3 中尚未修复。但它被报告为已知问题

您可以在 http://youtrack.jetbrains.net 对此问题进行投票/issue/TW-9584

Is not yet fixed in 5.0.3. But it's reported as known issue

You can vote for this issue at http://youtrack.jetbrains.net/issue/TW-9584

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