Snapshot dependency confusion

I'm trying to accomplish something in TeamCity that seems really simple but has been causing me much heartache.

I have three relevant build configurations:

Functional Tests: Runs a series of long running integration tests. Uses a Schedule Trigger to run 3 times daily.
Unit Tests: Runs a series of quick/short unit tests. Uses a VCS Trigger to run on every check in
Package: Runs when both Functional and Unit Tests builds have completed succesfully.

Requirements: Package build runs only when both the Unit and Functional Tests builds have completed. Which is to say no more than 3 times daily.

However, what I'm observing is that Package is triggered every time Unit Tests are run (i.e. on every VCS checkin). This, in turn, causes Functional Tests to also run on every VCS checkin, effectively negating the schedule triggered I've created.

I've attached screenshots of the Package configuration in the hopes that someone can tell me how to -reconfigure it so that my stated requirements are met.



Attachment(s):
triggers.png
deps.png
1 comment
Comment actions Permalink

Mitch,

the whole concept of snapshot dependencies is built around the putpose to execute build configurations against the same commit (or, in case of several repositories, against the same point in time). So, if we examine your build configurations, here is what happens:

1) 'Functional Tests' build configuration is built successfully against some commit in vcs (let's call this commit A)
2) later at some point in time user commits in vcs (let's call this commit B)
3) 'Unit Tests' configuration starts to execute
4) Finish build trigger fires
5) 'Package' configuration starts to execute
6) TeamCity sees, that it is missing snapshot dependency of type 'Functional Tests' arainst the commit B
7) Therefore, 'Functional Tests' is executed again, now against the commit B

I suggest that you alter your build configuration setup. This is what comes to mind:

Create 4 build configurations instead of 3: 'Build', 'Unit Tests', 'Functional Tests', 'Package'
- 'Build' will checkout the sources, compile code, build artifacts and publish them
- 'Build' will have finish build trigger, that will fire 'Unit Tests'
- 'Unit Tests' will have snapshot and artifact dependencies over 'Build', 'build from the same chain' option must be selected to maintain build chain between these configurations
- 'Functional Tests' will have artifact and snapshot dependencies over 'Build' and 'Unit Tests'. This will ensure, that only unit-tested code is allowed to proceed to functional tests.
- 'Functional Tests' can have schedulted build trigger, as is in your current setup. In this setup, however, neither 'Functional Tests' nor 'Unit Tests' will not trigger 'Package'
- 'Package' will have artifact dependency over last successful build of 'Functional Tests'. This will allow only functionally tested artifacts to be packaged for delivery.


Furthermore, in this setup allowes you to promote certain builds of 'Functional Tests' to be used as artifacts for packaging and certain builds of 'Unit Tests' to be used in 'Functional Tests'.  Also, in this setup, you can add finish build trigger to 'Functional Tests', so that if the tests succeed, code is packaged.

Main advantage of this setup lies in its linear structure, that excludes possibility, that long builds are triggered more often than necessary.

Before you make any changes, I would suggest to have a look at documentation topics:

1) Snapshot Dependencies
2) Artifact Dependencies
3) Build Promotion

0

Please sign in to leave a comment.