Snapshot dependencies across different VCS roots - what branch will be chosen?

We have two Git repositories, I'll call the first one "upstream" and the second one "downstream" because the second one depends on build results of the first one. (In reality, there are even _two_ upstream repositories, but I think this shouldn't matter and we can simplify the scenario for the sake of this question.)

In TeamCity, upstream has a "Packaging" build configuration that builds and packages code from the upstream repo. Downstream has a "Run tests" build configuration that invokes some tests on the results of the upstream "Packaging" build using the downstream repository's code. (To be exact, the downstream build only needs to read a build property published by the upstream build.)

To implement this, the two build configs use different VCS roots (one per repository) and the downstream "Run tests" build config has a snapshot dependency on the upstream "Packaging" build config.

Both repositories use feature branches. When I invoke a build on the downstream "Run tests" build config on branch A, what branch will TeamCity use for the snapshot dependency on the upstream "Packaging" build config?

Will it:
1. Always use the default branch of the upstream repo?
2. Try to match the branch names, i.e., find branch A on the upstream repo, too, falling back to something else?
3. Use a random branch, maybe the one with the most recent commit?
4. Something else altogether?

I couldn't find the answer to this on the docs page (https://www.jetbrains.com/help/teamcity/snapshot-dependencies.html).

If the answer is not 2, is there a good way to configure the builds so that 2 is implemented? This should work for both nightly builds as well as for continuous builds of the upstream repository, on different branches.

0
1 comment

Hi Fabian,

The option two is the correct answer here. TeamCity will try to use the same branch a build chain was started on in all builds of the chain. If branch specification of specific VCS roots do not cover the selected branch, these roots will fall back to the default branch.

The links I left in the previous paragraph should shed some additional light on how it works, but should you have any other questions, just let me know.

1

Please sign in to leave a comment.