Why do my builds pick up commits from the wrong Git branch?

I use TeamCity to build from my Git repositories. I have set up a common build template and several builds based on the template, each build configuration works on a different branch or set of branches. I have one build for integration builds, another for releases, and so on. I control this using the branch specification, which I have parameterized in the template into a variable called %BranchSpecification%. Each build configuration supplies its own vallue for %BranchSpecification%. I'm using GitFlow, so for example, my integration builds have a branch specification of

+:refs/heads/feature/(*)

+:refs/heads/(develop)

while my release builds have a branch specification of

+:refs/heads/(master)

However, I've noticed that sometimes the integration build also picks up commits on the master branch and builds those. I'm not sure why that happens, it was not what I expected.

Each build configuration has a single VCS trigger and I have not set the branch filter in any of my configurations, it is at the default value of

+:*

I'm not sure why a seperate branch filter is needed, isn't that taken care of by the branch specification? Why would my integration build trigger on commits on the master branch when that is not part of the branch specification?

thanks,
TIm Long

7 comments
Comment actions Permalink

I am facing similar sort of issue. I have a single build configuration to build from develop, master and any release branch. My Branch specification section looks like
+:refs/heads/develop
+:refs/heads/master
+:refs/heads/release*
and I have set up Default branch as refs/heads/develop
At the moment I have below branches:

refs/heads/develop
refs/heads/master
refs/heads/release/v1.0

However I have noticed a release/v1.0 branch build got triggered without any commit in any of the release branches. It also picked up last couple of changes from develop branch.
Another issue I have noticed is that when we merged(rebase) from develop to release/v1.0, a relaese/v1.0 build triggered, rightly so, but it doesn't display any changes in release/v1.0 branch.

0
Comment actions Permalink

Have you copied a project? Then it could be this Issue: https://youtrack.jetbrains.com/issue/TW-37748 (we had a similar problem)

0
Comment actions Permalink

No, I have not copied the project.

0
Comment actions Permalink

Hi Mohammad,

Could you please attach screenshot that shows the problem: build which was triggered incorrectly and changes which should not be included? Also please attach teamcity-vcs.log.

0
Comment actions Permalink

Is there any update on this issue? I have got a similar issue. I have got different projects setup in a single repo and configured vcs checkouts and triggers on folder level. I created a build for release branch but it took the latest commit history from the main branch though the source code seems to be right. Head revision seems to be ok too but it just the changelist got picked from the main branch. Any ideas? 

0
Comment actions Permalink

I just had the same issue happen to me as @Ramesh Ramalingam. I set up a new build in my TeamCity project, by copying an existing build which had most of the necessary configuration. Then edited the build to point to the correct VCS root.

Once the initial build ran, the build version is correct for the GIT branch which the VCS root points to, and the build log confirms each module version is also correct as per the branch ... however the change log is completely wrong, seems to have been compiled from master instead of the branch which was built. This has really knocked my confidence in the build. Am gonna delete the build and set up from scratch to see if this causes the change log to be reported correctly, since a comment above mentions copying.

0
Comment actions Permalink

Hi Sean,

 

While teamcity attempts to keep IDs properly tracked across copies, depending on how you have copied it, if it's manually, it might create issues with IDs. Teamcity will track those automatically if you do the copy via the UI or via other methods, but manual changes might sometimes not be tracked properly.

 

If you can consistently replicate a situation where the revision IDs (or changelog) are incorrectly posted to a build, but the build is built with the proper revision, please send us the appropriate screenshots and build log to our issue tracker here: https://youtrack.jetbrains.com/issues/TW

There might be a bug somewhere that we might need to track down, but we would need enough data before we can troubleshoot it.

0

Please sign in to leave a comment.