Build Checkout Directory
The build checkout directory is a directory on the TeamCity agent machine where all the sources of all builds are checked out into.
If you use the agent-side checkout mode, the build agent checks out the sources into this directory before the build.
In case you use the server-side checkout mode, the TeamCity server sends incremental patches to the agent to update only the files changed since the last build in the given checkout directory.
With the manual checkout mode, no sources will be checked out, but the default build checkout directory will still be created to check out the sources via a build script. The directory will not be cleaned automatically unless its expiration period is configured as described below.
The sources are placed into the checkout directory according to the mapping defined in the VCS Checkout Rules.
The checkout directory is configured in the Checkout Settings section on the Version Control Settings page; the default Auto (recommended) value is strongly advised, but it is possible to configure a custom checkout directory as described below.
If you want to investigate an issue and need to know the directory used by the build configuration, you can get the directory from the build log, or you can refer to the
Agent Work Directory
>/directory.map generated file which lists build configurations with the directories they used last.
By default, this is also the directory where builds will run.
For checkout handled by TeamCity (the server-side or agent-side checkout mode), TeamCity keeps track of the last revision checked out into each checkout directory on the agent and for the new build applies an incremental patch from the last used revision to the revision of the current build.
The revisions used can be looked up on the Changes tab of the build results page.
Incremental checkouts mean that any files not created or modified by TeamCity (for example, by the previous build scripts) are preserved in their modified state (unless dedicated VCS root-specific reset options are used).
That is why it is recommended to:
make sure the builds perform a clean procedure as the first step of the build for all the files that affect the build and might have been produced by previous builds. Typical files are compilation output, tests reports, build produce artifacts.
make sure the builds never modify or delete the files under version control.
If TeamCity detects that it cannot build an incremental patch, a clean checkout in enforced. It can also be enforced manually or configured to be performed on each build.
Custom checkout directory
In most cases, the default Auto (recommended) setting will cover your needs. With this default checkout directory, TeamCity ensures the best performance and consistent incremental sources updates. The name of the default automatically created directory is generated as follows:
Agent Work Directory
>/<VCS settings hash code>. The VCS settings hash code is calculated based on the set of VCS roots, their checkout rules and VCS settings used by the build configuration (checkout mode). Effectively, this means that the directory is shared between all the build configurations with the same VCS settings.
If for some reason you need to specify a custom checkout directory (for example, the process of creating builds depends on some particular directory), make sure that the following conditions are met:
the checkout directory is not shared between build configurations with different VCS settings (otherwise, TeamCity will perform clean checkout each time another build configuration is built in the directory);
the content of the directory is not modified by processes other than those of a single TeamCity agent (otherwise TeamCity might be unable to ensure consistent incremental sources update). If this cannot be eliminated, make sure to turn on the clean build checkout option for all the participating build configurations. This rule also applies to two TeamCity agents sharing the same working directory. As one TeamCity agent has no knowledge of another, the other agent appears as an external process to it.
Note that the content of the checkout directory can be deleted by TeamCity under certain circumstances.
Automatic Checkout Directory Cleaning
With the server-side and agent-side checkout modes, checkout directories are automatically deleted from the disk if not used (no builds were run on the agent using the directory as the checkout directory) for a specified period of time (8 days by default) or when another build requires more free disk space than available. With the manual checkout mode, automatic directory cleaning is not performed unless the directory expiration period is configured.
It is recommended to use the Free Disk Space build feature to ensure the build gets enough disk free space on the build agent.
There are also obsolete manual controls for old checkout directories clean-up:
The time frame for automatic directory expiration can be changed by specifying a new value (in hours) by either of the following ways:
teamcity.agent.build.checkoutDir.expireHoursagent property in the
system.teamcity.build.checkoutDir.expireHoursbuild configuration property
0will cause deleting the checkout directories right after the build finishes
neverwill let TeamCity know that the directory should never be deleted by TeamCity
defaultwill enforce using the default value
Expiration-based directory cleaning is performed in the background when the build agent is idle (no builds are running).
Administrator's Guide: Configuring VCS Settings