# Manage artifact retention rules

> Learn about artifact retention rules that manage build artifacts and control storage costs.

Use artifact retention rules to automatically delete artifacts for builds based on age or the number of builds. Deleting build artifacts saves on storage costs.

Unity Build Automation (UBA) evaluates the artifact retention rules during the next scheduled evaluation. UBA evaluates artifact retention rules every hour.

When UBA deletes artifacts based on retention rules, it keeps a record of the build target. This build target provides details such as build statistics, storage size, and configuration. You can view build targets and a summary of the active artifact retention rules in **Build History**.

You must have the owner permission or the manager permission for the selected project to manage artifact retention rules.

By default, a project has no artifact retention rules configured. This means that UBA retains build artifacts according to the [Unity DevOps retention schemas](/devops/retention-schemas.md).

To manage artifact retention rules:

1. In the [Unity Dashboard](https://cloud.unity.com), go to **Build Automation** > **Settings**.
2. Go to **Project settings** and to **Artifact Retention rules**.
3. To delete build artifacts based on the age of a build, enable **Time-based rule** and set the build age in days. For more information, refer to [Time-based rule](#time-based-rule).
4. To delete build artifacts based on build count, enable **Build count rule** and set the maximum number of builds. For more information, refer to [Build count rule](#build-count-rule).
5. For either retention rule, enable **Retain logs** to keep build logs when UBA deletes other build artifacts. When enabled, UBA ignores builds with only logs during rule evaluation. For more information, refer to [Artifacts and logs](#artifacts-and-logs).
6. Select **Save** to save artifact retention rules.

## Time-based rule

Use the time-based artifact retention rule to delete artifacts from builds that are older than a specified number of days. UBA applies this retention rule to builds based on the following criteria:

* The build isn't a favorite build.
* The build has a terminal build status of success, failure, canceled, or unknown.
* The build has artifacts, or the build has only logs and **Retain logs** is disabled.

When a build matches the criteria, UBA compares the build's completion date with the current date. If the build is older than the specified number of days, UBA deletes its build artifacts. You can specify a minimum age of 1 day and a maximum age of 365 days. Enable **Retain logs** to keep logs when UBA deletes build artifacts.

## Build count rule

Use the build count artifact retention rule to delete build artifacts when the number of builds exceeds a specified limit. UBA counts a build when its terminal build status is success, failure, canceled, or unknown. The build must also match one of the following conditions:

* The build isn't a favorite build.
* The build has artifacts.
* The build has only logs and **Retain logs** is disabled.

When a build matches the status and conditions, UBA counts the build. If the build count exceeds the specified limit, UBA deletes the build artifacts for the oldest build based on build completion date. You can specify a minimum limit of 1 build and a maximum limit of 1000 builds. Enable **Retain logs** to keep logs when UBA deletes build artifacts.

## Artifacts and logs

Build artifacts include all assets, files, and logs created when UBA builds a project. Build logs provide details on the build process and use less storage space than other artifacts.

If you enable **Retain logs** for a retention rule, UBA keeps logs when it deletes build artifacts. UBA also ignores builds with logs when it evaluates the retention rule.

If you disable **Retain logs** for a retention rule, UBA considers builds with logs the same as builds with artifacts. This means UBA deletes build logs with other build artifacts. For example, for the build count retention rule, if you disable **Retain logs**, UBA counts builds with logs when evaluating the build count.
