VCS Checkout Rules allow you to check out a part of the VCS root configured and to map directories from the version control to subdirectories in the build checkout directory on a Build Agent. Thus, you can define a VCS root for the entire repository and make each build configuration checkout only the relevant part of it.
The Checkout Rules affect the changes displayed in the TeamCity for the build and the files checked out for the build on agent. To display changes, but not to trigger a build for a change, use VCS Trigger Rules.
The general recommendation is to have a small number of VCS roots (pointing to the root of the repository) and define what is checked out by a specific build configuration via checkout rules.
To add a checkout rule, go to the build configuration's Version Control Settings page, locate the VCS root in the list, and click the Edit checkout rules link. A pop-up window will appear where you can enter the rule. Use the VCS repository browser to select a directory to check out.
The general syntax of a single checkout rule is as follows:
When entering rules please note the following:
- To enter multiple rules, each rule should be entered on a separate line.
- For each file the most specific rule will apply if the file is included, regardless of what order the rules are listed in.
- If you don't enter an operator it will default to
Rules can be used to perform the following operations:
Checks out the root into
An example with three VCS checkout rules:
In the above example, the first rule excludes the
src/help directory and its contents from checkout. The third rule is more specific than the second rule and maps the
src/samples path to the
samples path in the Build Agent's default work directory. The second rule maps the contents of the
src path to the
production/sources on the build agent, except
src/help which was excluded by the first rule and
src/samples which was mapped to a different location by the third rule.