Running build can cause you to run a commit on a different branch than the branch you chose

Hi!

Lets say i have two branches, branch A and B. On branch A i have commits 1, 2 and 3. And on branch B i have commits 4, 5 and 6.

 

Now, when we select "Run custom build" on a build and then select the Changes tab. Now we select branch A as "build branch". After this we can see commits 1, 2 and 3 appear in the "Included changes" list. If we now select commit 2 in that list and change to branch B in the build branch section, we expect to see commits 4, 5 and 6. But we can also still see commit 2 from branch A in the Included changes list. I.E the list "Include changes" keeps the state of the selected commit from the previously selected branch untill the option "<latest changes at the moment the build is started>" is chosen. If we now run the build with this configuration, i.e branch B and commit 2, we expect that since commit 2 wont be found on this branch, TeamCity will select the latest branch that can be found on branch B and build with that. But no, instead TeamCity is starting to search for commit 2 on other branches than branch B and finds it in branch A and runs the build with this code from a completely different branch than the one we selected.

 

It definitely feels like the "Include changes" list should never keep a state with a commit from a different branch than the one selected in "Build branch". And if the state is never cleared we should at least never be able to run the build with a commit on a different branch than the selected branch - TeamCity should rather choose latest changes on the selected branch. We have tried to find if this is a configuration in the version control settings but it seems like a bug?

2
1 comment
Avatar
Permanently deleted user

We have been running into this as well and its becoming quite a pain. The VCS roots are always caching the latest change (interval or webhook) and search for that head commit in all branches. It then does what you describe and checks out the wrong branch. From other topics I've read it's always described as working as intended and that Teamcity is being smart and saving you bandwidth by not checking out the whole VCS root. That would be great if it actually pulled the branch we needed. We are close to adding in a build step that just does `git checkout %env.branch%` until this "feature" is fixed.

https://youtrack.jetbrains.com/issue/TW-46810

https://teamcity-support.jetbrains.com/hc/en-us/community/posts/205409690-Teamcity-not-respecting-branches-in-dependent-builds

2

Please sign in to leave a comment.