Add-on behaviours that enhance build configurations without modifying build steps — all 15+ features in TeamCity 2017.2.2 with setup instructions and gotchas
Build features are optional add-ons configured under Build Configuration → Build Features → Add build feature. Multiple features can be active simultaneously. They are applied around the build steps without modifying them.
Already covered in Phase 5. Quick reference for configuration:
| Publisher | URL | Auth | Token scopes |
|---|---|---|---|
| GitHub.com | https://api.github.com | PAT or connection | repo:status |
| GitHub Enterprise | https://ghe.company.com/api/v3 | PAT | repo:status |
| Bitbucket Cloud | https://api.bitbucket.org | Username + app password | Repositories: write |
| GitLab | https://gitlab.com/api/v4 | Personal access token | api |
Covered in Phase 5. Additional configuration option not covered there:
Only build PRs targeting a specific branch. Enter branch patterns:
# Only build PRs targeting main or develop
refs/heads/main
refs/heads/develop
# Build PRs targeting any release branch
refs/heads/release/*
Options: All (including forks), Members (org members only), Members and external contributors with write access. For public repos, use Members to prevent fork-based CI abuse.
JaCoCo integration instruments Java bytecode and reports line, branch, and method coverage. The coverage report appears in the build's Code Coverage tab and on the build overview as a percentage bar.
TeamCity injects JaCoCo agent into the JVM automatically when the JaCoCo build feature is enabled — no changes to your pom.xml required for basic coverage.
** (all classes). Narrow to your source packages for accurate results: com/yourcompany/**.**/*Test*, **/*Generated*.For multi-module Maven projects, JaCoCo must aggregate coverage across modules. Use the jacoco:report-aggregate goal in a parent pom, or configure TeamCity to look for coverage files in all modules: **/jacoco.exec. Without aggregation, coverage is only reported for the last module that ran tests.
Scans Java source files for duplicated code blocks. Reports are shown in the Duplicates tab of the build.
| Setting | Recommended value |
|---|---|
| Minimum token count | 150 (short duplicates are often acceptable patterns) |
| Source paths | src/main/java (exclude test sources) |
| Exclude | Generated sources: target/generated-sources/** |
| Fail on new duplicates | Optional — only fail if count INCREASES vs previous build |
Runs IntelliJ IDEA's code inspections on the source — Checkstyle, PMD, FindBugs/SpotBugs, and IDEA's own inspections (unused imports, null pointer risks, etc.).
The Inspections build feature requires a full IntelliJ IDEA installation on the build agent — not just the JDK. IntelliJ is typically not installed on CI servers. This feature is mainly useful if you have a dedicated agent with IntelliJ installed. Most teams use Maven Checkstyle/PMD plugins instead, which run without IntelliJ.
# Instead of IntelliJ inspections, use Maven Checkstyle runner:
# Build step: Maven runner
# Goals: checkstyle:check
# Fails build if violations exceed configured threshold
# Or inline in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failsOnError>true</failsOnError>
</configuration>
</plugin>
Replaces tokens in files before build steps run. Ideal for injecting the build number into version files, configuration files, or assembly info files. The replacement is applied on the agent's working copy — the original files in VCS are not modified.
# File Content Replacer configuration:
File pattern: src/main/resources/version.properties
Find what: APP_VERSION=SNAPSHOT
Replace with: APP_VERSION=%build.number%
Regular expression: No (literal text replacement)
File pattern: **/AssemblyInfo.cs
Find what: \[assembly: AssemblyVersion\(".*"\)\]
Replace with: [assembly: AssemblyVersion("%build.number%.0")]
Regular expression: Yes
File Content Replacer runs before all build steps. This means the modified file is in place when Maven/Gradle/MSBuild runs. The replacement is applied to the working copy only — it does not affect VCS or committed code.
The SSH Agent build feature starts an ssh-agent process on the agent and loads a specified key. Build steps can then make SSH connections (git push, rsync, ssh deploy) using that key without specifying credentials explicitly.
$SSH_AUTH_SOCK).# In a Command Line deploy step:
# No need to specify -i /path/to/key — ssh-agent handles it
rsync -avz --delete dist/ deploy@prod-server:/var/www/app/
ssh deploy@prod-server "systemctl restart app"
The SSH Agent build feature loads a key into ssh-agent so your own scripts can use it. The SSH Exec build step runner (Phase 4) is a different thing — it directly executes a command on a remote host over SSH. They can be used together: SSH Agent provides the key, SSH Exec runner uses it for deployment.
The Docker Support build feature handles Docker registry login/logout and optionally cleans up Docker images created during the build.
# With Docker Support feature active, build steps can use docker commands
# without logging in explicitly:
# Build step: Command Line
docker build -t registry.yourcompany.com/myapp:%build.number% .
docker push registry.yourcompany.com/myapp:%build.number%
# The Docker Support feature:
# 1. Runs docker login BEFORE steps (using stored credentials)
# 2. Runs docker logout AFTER steps
# 3. If cleanup enabled: removes the pushed image tag after build
Swabra detects files created during the build that are not part of the VCS checkout and removes them after the build. Prevents build pollution — if build A creates a temp file, build B (on the same agent) won't accidentally pick it up.
| Setting | Description |
|---|---|
| Clean checkout if cannot restore clean directory | Forces full clean checkout if Swabra can't restore the clean state. Safer but slower. |
| Lock files for writing during build | Tracks which files are modified; removes extra files after build ends |
| Strict cleanup | Removes ANY file not in VCS — useful when builds generate files that must not leak between runs |
Collects CPU, memory, and disk I/O metrics on the agent during the build. Results appear in the build's Build Statistics charts. Useful for diagnosing builds that are getting slower over time.
No configuration required — just add the build feature and data is collected automatically at 3-second intervals during the build.