Snapshot dependencies, artifact dependencies, build chain visualization, composite builds, passing parameters across chains — and a complete Build → Test → Package → Deploy pipeline
A snapshot dependency enforces that two build configurations use the exact same source code revision. When Build B has a snapshot dependency on Build A, TeamCity guarantees:
| Option | What it does | Recommended |
|---|---|---|
| Do not run new build if suitable one exists | Reuses an existing passing build of the upstream config — avoids redundant rebuilds | ✅ Yes for most cases |
| Run new build even if there is a suitable one | Always triggers a fresh build of upstream | Only for guaranteed-fresh builds |
| Only use successful builds from suitable ones | Skips failed upstream builds when looking for a "suitable" build to reuse | ✅ Yes |
| Run on the same agent | Forces the downstream to run on the same agent as the upstream | Only needed if builds share a non-exported filesystem state |
TeamCity searches for an existing build of the upstream config that used the same VCS revision. If found and successful, it reuses it (skips re-running). This is the key to efficient build chains — a commit that already passed the Build stage won't rebuild it just because Deploy was triggered again.
If "Clean sources" is enabled on the downstream config, its checkout is wiped even though the snapshot ensures the same revision. This is correct behaviour — the clean checkout is about the working directory state, not the revision.
For the "suitable build" matching to work, both build configurations must use the same VCS Root (or at least a VCS Root pointing to the same repository URL). If Build and Deploy use different VCS Root objects (even pointing to the same repo), TeamCity cannot match revisions and will always run a fresh upstream build.
An artifact dependency copies files published by one build configuration into the working directory of another, before the build starts. It does not enforce build ordering — it just copies files. Combine with a snapshot dependency for ordered artifact passing.
# Artifact path examples (relative to producing build's artifact root):
# Copy a specific JAR into current dir
artifacts/myapp-*.jar
# Copy all files from a published directory
release/** => downloaded-release
# Copy specific files to a named directory
target/myapp.jar => libs
target/config.properties => config
# Pattern syntax:
# source-pattern => target-dir (optional)
# source-pattern supports: *, **, ?
# target-dir: where to place files in downstream working dir
| Option | Which upstream build's artifacts to use |
|---|---|
| Build from the same chain | Use artifacts from the specific upstream build in the current chain. Most common — guarantees same revision. |
| Last successful build | Use the most recent passing build, regardless of chain. Useful for cross-project dependencies. |
| Last pinned build | Use the most recent build with a pin (manually marked as important). |
| Build with specific number | Fixed build number — for pinned release builds. |
| Last finished build | Most recent build regardless of status — rarely useful. |
TeamCity automatically generates a visual build chain diagram. To view it: click any build in the chain → Dependencies tab → Build chain view.
The chain view shows the status (green/red/running) of each build in the chain, the build number, start time, and duration. Failed builds are immediately visible — you can click to jump to the log.
A composite build configuration aggregates results from multiple builds into a single "pass/fail" result. It has no build steps of its own — it simply waits for all its snapshot dependencies to complete and reports a combined status.
Use cases:
When enabled on a snapshot dependency, TeamCity ensures the downstream build runs on the same agent as the upstream build. This is needed when:
If you require same-agent for a 4-step chain, all 4 steps are tied to one agent. If that agent is busy, the entire chain queues — even if other agents are idle. Only use same-agent when genuinely necessary. Prefer artifact publishing for passing files between builds.
Clean checkout on a downstream config wipes its working directory. This is independent of the snapshot dependency — the same revision is checked out fresh. Be aware that artifact dependencies run AFTER clean checkout — the downloaded artifacts won't be deleted by clean checkout.
# Execution order within a downstream build:
# 1. Clean checkout (if enabled) — wipes working dir
# 2. VCS checkout — checks out the snapshot-matched revision
# 3. Artifact dependencies downloaded — files placed in working dir
# 4. Build steps run
# So artifact dependencies survive clean checkout — ✅ correct behaviour
Downstream builds can read any parameter from an upstream build using the dep. prefix (see Phase 8). This includes predefined parameters like the build number:
# In Deploy build config (which has snapshot dep on Build):
# Read Build's build number:
dep.ProjectId_BuildConfigId.build.number
# Example with a real config ID:
# Project: BackendServices, Config: Build → ID: BackendServices_Build
dep.BackendServices_Build.build.number
# In a deploy step:
echo "Deploying artifact version: %dep.BackendServices_Build.build.number%"
kubectl set image deployment/myapp myapp=registry/myapp:%dep.BackendServices_Build.build.number%