How to Limit Artifacts of TeamCity Builds?

To save disk space and avoid performance problems, you can limit artifacts stored in specific TeamCity builds and projects. There are three main ways to do this:

  • Pack multiple artifact files into a single archive.
  • Limit the size of artifact files and the number of artifacts per build.
  • Configure automatic clean-up of unnecessary files.

Pack build artifacts into an archive

TeamCity can automatically create an archive from build artifacts before publishing them. To configure this behavior, open General Settings of a build configuration and specify artifact paths (newline- or comma-separated patterns) in the following format:

[+:|-:]source => target_archive.*, where:

  • [+:|-:]source – a path to the files or directories to be published as build artifacts (+:) or excluded from publishing (-:). It is recommended to use source paths relative to the build checkout directory, although absolute paths are also supported.
  • target_archive.* – a path to an archive that TeamCity should create to pack artifacts, where .* is the archive extension. Supported archive types are zip, 7zip, jar, tar, and tar.gz. A target path cannot be absolute – specify it relative to the build checkout directory.

For example, to pack all files and subdirectories stored in the directory_name directory into the archive_name ZIP archive, enter the following in the Artifact paths field:

directory_name =>

See this documentation article for more details and examples on how to configure artifact paths.

Limit the size and number of artifact files

You can specify the maximum allowed size of a build artifact file and the maximum number of artifacts per build globally on the TeamCity server. To do this, use the corresponding settings in the Build Settings section of Administration | Global Settings.

Define clean-up rules

You can instruct TeamCity to automatically delete old and unnecessary artifacts of a specific build configuration. To do this, configure the clean-up rules in Project Settings | Clean-up Rules:

  • Click the Base rule row under a build configuration you want to change. If the base rule row is hidden, click Show 1 inherited rule (each build configuration inherits a base rule from its parent project by default).
  • In the Clean artifacts section of the pop-up dialog, select the Custom policy option and specify a rule to remove build artifacts. For example:
    • Remove artifacts of all builds older than the n-th successful build.
    • Remove artifacts of all builds that are older than n days since the last successful build.
    • Remove artifacts by names according to the specified patterns.

      In the Artifact patterns field, enter newline-separated patterns for artifact names to add or exclude matching artifacts from the clean-up. For example:

      • +:**/file*.* – removes artifacts that contain “file” in their names.
      • -:**/file*.jar – excludes .jar artifacts with “file” in their names from clean-up.
  • In the Dependencies section of the base rule dialog, you can specify whether to delete or preserve artifacts of dependency builds that are parts of a chain.