使用Git触发TeamCity非确定性构建

时间:2022-10-26 03:19:36

I use a GitFlow branching strategy. I like to have 3 build configurations per project:

我使用GitFlow分支策略。我喜欢每个项目有3个构建配置:

  • Integration - builds from develop, feature/* and hotfix/* with branch specification
    • +:refs/heads/(develop)
    • +:refs/heads/feature/(*)
    • +:refs/heads/develop/(*)
    • +:res/heads/(hotfix/*)
  • 集成 - 使用开发,功能/ *和hotfix / *构建分支规范+:refs / heads /(develop)+:refs / heads / feature /(*)+:refs / heads / develop /(*)+:res /头/(修补程序/ *)

  • Beta - builds from beta/* with branch specification

    Beta - 使用分支规范从beta / *构建

    • +:refs/heads/(release/*)
  • Release - builds from master with branch specification

    发布 - 使用分支规范从master构建

    • +:refs/heads/(master)

Note the use of brackets to set my preferred branch names. The reason I have these 3 builds is because I use the build configuration name as part of the build name, so for example I get builds in the format 1.2.3-Integration.27, the final number '27' is a project-wide shared build counter. I also take different post-build actions in the different configurations, for example the release configuration carries out deployment actions.

请注意使用括号来设置我的首选分支名称。我有这3个版本的原因是因为我使用构建配置名称作为构建名称的一部分,所以例如我得到1.2.3-Integration.27格式的构建,最终的数字'27'是一个项目范围共享构建计数器。我还在不同的配置中采取不同的后构建操作,例如发布配置执行部署操作。

As an example of what I call 'non determinism', I have just merged a feature branch via a pull request into develop. I get a build in my Integration build configuration, which builds the develop branch. But then I also get builds on my other two build configurations, even though nothing in their branch specifications has changed; this is definitely not what I want because my release configuration, for example, deploys things. Here's a screen shot with the offending builds highlighted: 使用Git触发TeamCity非确定性构建

作为我称之为“非确定性”的一个例子,我刚刚通过pull请求将一个功能分支合并到了develop中。我在Integration构建配置中构建了一个构建开发分支的构建。但是,即使其分支规范中没有任何内容发生变化,我也可以在其他两个构建配置上构建。这绝对不是我想要的,因为我的发布配置,例如,部署的东西。这是一个突出显示违规构建的屏幕截图:

Update - Additional Information Here is the overview of an 'offending build' 使用Git触发TeamCity非确定性构建 And here is the trigger configuration 使用Git触发TeamCity非确定性构建

更新 - 附加信息以下是“违规构建”的概述以下是触发器配置

I'm clearly not understanding something about how TeamCity is supposed to work with Git. I am under the impression that build configurations are only supposed to build things that fall under their Branch Specification. Where are the other two coming from? Why do these builds get triggered when the branch specification doesn't include develop (or refs/heads/develop)? Is there a way I can stop this from happening?

我显然不了解TeamCity应该如何与Git合作。我的印象是,构建配置只应构建属于其分支规范的内容。其他两个来自哪里?当分支规范不包括develop(或refs / heads / develop)时,为什么会触发这些构建?有没有办法阻止这种情况发生?

I've tried raising this on the JetBrains support forum but I don't seem to be getting any traction there, so I thought I'd reach out to the * community.

我试过在JetBrains支持论坛上提出这个问题,但我似乎没有任何牵引力,所以我想我会联系*社区。

1 个解决方案

#1


If you have a build trigger that triggers any time there are changes, you will get this behaviour. I have a very similar setup in my project and I normally specify all branch specifications in the trigger build section.

如果你有一个构建触发器,只要有变化就会触发,你会得到这种行为。我的项目中有一个非常类似的设置,我通常在触发器构建部分中指定所有分支规范。

#1


If you have a build trigger that triggers any time there are changes, you will get this behaviour. I have a very similar setup in my project and I normally specify all branch specifications in the trigger build section.

如果你有一个构建触发器,只要有变化就会触发,你会得到这种行为。我的项目中有一个非常类似的设置,我通常在触发器构建部分中指定所有分支规范。