Search code examples
gitteamcitygit-flowbuildconfiguration

TeamCity non-deterministic build triggering with Git


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

  • Integration - builds from develop, feature/* and hotfix/* with branch specification
    • +:refs/heads/(develop)
    • +:refs/heads/feature/(*)
    • +:refs/heads/develop/(*)
    • +:res/heads/(hotfix/*)
  • Beta - builds from beta/* with branch specification

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

    • +: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.

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: enter image description here

Update - Additional Information Here is the overview of an 'offending build' enter image description here And here is the trigger configuration enter image description here

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?

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 StackOverflow community.


Solution

  • 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.