Setting the dependency by other build's sources you can ensure that a build will start only after the one it depends from is run and finished. See details at Snapshot Dependency.
To add a snapshot dependency, on the Dependencies page of the build configuration settings, click the Add new snapshot dependency and specify the following options:
| Depend on
|| Specify the build configuration that the current build configuration should depend on.
| Do not run new build if there is a suitable one
|| If the option is enabled, TeamCity will not run a build, if another running or finished build with same revisions exists. However, when a parent build (a build with snapshot dependency to another build) is triggered, the child build will be triggered, too. Then, when the changes for the child build are collected, this child build will be removed from the queue and dependency will be set to a finished build.
| Only use successful builds from suitable ones
|| TeamCity will take already running build only if it is not failing or failed.
| Run this build if dependency has failed
|| If enabled and dependency fails, the build of this build configuration will still be run.
| Run build on the same agent
|| When enabled, and B snapshot-depends on A, then A is run only on agents compatible with both B and A.