> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/artifact-registry/3.0/lifecycle-management/lifecycle-rule-fields.md).

# Lifecycle rule fields reference

Complete field reference for Harness Artifacts cleanup rules and retention rules, covering scope, pattern filters, criteria, schedule, and execution statuses.

This page lists every configurable field in a cleanup rule and a retention rule, with valid values, defaults, and notes on behaviour.

## Rule types at a glance

|                     | Cleanup rule                                                     | Retention rule                                                 |
| ------------------- | ---------------------------------------------------------------- | -------------------------------------------------------------- |
| **Purpose**         | Delete versions that match criteria on a schedule                | Protect versions from all deletion, permanently                |
| **Has criteria**    | Yes (up to 3)                                                    | No, a match protects the version                               |
| **Has schedule**    | Yes                                                              | No, evaluated automatically during cleanup runs                |
| **Execution order** | Runs first; identifies candidates                                | Runs second; removes protected versions from the candidate set |
| **Wins when**       | A version matches no retention rule and no deployment protection | A version matches the rule's pattern filters                   |

## Scope fields

Scope fields appear on both cleanup and retention rules.

### Name

|                |                                                                       |
| -------------- | --------------------------------------------------------------------- |
| **Required**   | Yes                                                                   |
| **Format**     | Free text string                                                      |
| **Visible in** | Rule list, execution list, protection badge ("Protected by `<name>`") |

### Description

|              |                  |
| ------------ | ---------------- |
| **Required** | No               |
| **Format**   | Free text string |

### Registry scope

Defines which registries the rule applies to.

| Option                  | Behaviour                                                                                               |
| ----------------------- | ------------------------------------------------------------------------------------------------------- |
| **All Registries**      | Applies to every registry under the current scope. Dynamic, includes registries created after the rule. |
| **Specific Registries** | Applies only to the registries you select from the dropdown. Registries appear as removable tags.       |

{% hint style="info" %}
**Scope hierarchy**

Rules are created at the account, organization, or project scope. A rule created at account scope can target All Registries and covers every registry in the organization and all projects under it. Project-level cleanup rules cannot override account-level retention rules.
{% endhint %}

### Package type

Narrows the rule to one artifact format or leaves it open.

| Option                | Behaviour                                             |
| --------------------- | ----------------------------------------------------- |
| **All Package Types** | Evaluates every format in the targeted registries     |
| A specific format     | Evaluates only that format; other formats are skipped |

Supported formats: Docker, Maven, npm, NuGet, Go, PyPI, Cargo, Helm, Debian, RPM, Alpine, Conda, Raw, and others listed in [Supported formats](https://developer.harness.io/artifact-registry/3.0/get-started/supported-formats.md).

***

## Pattern filter fields

Pattern filters restrict which packages and versions the rule evaluates. Filters are **optional** on both rule types. A rule with no pattern filters evaluates every package and version in the targeted registries.

The available filter fields depend on the package type selected.

### Docker

| Field                     | Matches against                                  | Example regex |
| ------------------------- | ------------------------------------------------ | ------------- |
| **Package Name Patterns** | The image name, such as `my-org/payment-service` | `my-org/.*`   |
| **Tag Patterns**          | The tag, such as `latest` or `staging-20241101`  | `staging-.*`  |

### Maven

| Field                      | Matches against                              | Example regex      |
| -------------------------- | -------------------------------------------- | ------------------ |
| **Group ID Patterns**      | The Maven group ID, such as `com.example`    | `com\.example\..*` |
| **Artifact Name Patterns** | The artifact ID, such as `payment-service`   | `payment-.*`       |
| **Version Patterns**       | The version string, such as `2.4.1-SNAPSHOT` | `.*-SNAPSHOT`      |

### All other package types

| Field                     | Matches against            | Example regex |
| ------------------------- | -------------------------- | ------------- |
| **Package Name Patterns** | The package or module name | `frontend-.*` |
| **Version Patterns**      | The version string         | `1\.0\..*`    |

{% hint style="info" %}
**How multiple patterns combine**

Within a single field, entering multiple patterns creates OR logic: a version matches if it satisfies any one of the patterns. Across fields, the relationship is AND: a Docker version must match both the name pattern and the tag pattern to be included.
{% endhint %}

***

## Regular expression syntax

Pattern filter fields accept regular expressions, not glob syntax. The most common substitutions:

| Glob intent                             | Regex equivalent | Notes                                                                        |
| --------------------------------------- | ---------------- | ---------------------------------------------------------------------------- |
| Match any characters (`*`)              | `.*`             | `.` matches any single character; `*` means zero or more                     |
| Match a literal dot                     | `\.`             | An unescaped `.` matches any character                                       |
| Start with prefix                       | `prefix-.*`      | No leading anchor required; prefix is matched as a substring unless anchored |
| End with suffix                         | `.*-suffix`      |                                                                              |
| Exact match                             | `^exact-value$`  | Use `^` and `$` anchors to prevent substring matching                        |
| Any version starting with `1.0.`        | `1\.0\..*`       | Escape the dots                                                              |
| SNAPSHOT versions                       | `.*-SNAPSHOT`    |                                                                              |
| Semantic version (for example, `2.4.1`) | `\d+\.\d+\.\d+`  | Matches three numeric segments separated by dots                             |
| Any tag except `latest`                 | `(?!latest).+`   | Negative lookahead                                                           |

***

## Cleanup criteria fields

A cleanup rule requires at least one criterion. When multiple criteria are enabled, **all** must be true for a version to become a deletion candidate (AND logic).

### Keep last N versions

|                  |                                                                                                                       |
| ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| **What it does** | Retains the N most recently uploaded versions of each package. Versions beyond this count become deletion candidates. |
| **Valid values** | Any positive integer                                                                                                  |
| **Ordering**     | Upload timestamp, not semantic version. Version `2.0.0` uploaded before `1.9.9` is treated as the older version.      |
| **Scope**        | Applied per package. If a registry contains ten packages, each package retains its own last N versions independently. |

### Delete artifacts older than X days

|                  |                                                                                               |
| ---------------- | --------------------------------------------------------------------------------------------- |
| **What it does** | Marks versions whose upload timestamp is more than X days in the past as deletion candidates. |
| **Valid values** | Any positive integer (days)                                                                   |
| **Clock**        | Measured from upload timestamp to the cleanup rule execution time.                            |

### Delete if not downloaded in last X days

|                        |                                                                                                       |
| ---------------------- | ----------------------------------------------------------------------------------------------------- |
| **What it does**       | Marks versions that have had no download activity in the last X days as deletion candidates.          |
| **Valid values**       | Any positive integer (days)                                                                           |
| **No download record** | Versions with no recorded download are treated as never downloaded and become candidates immediately. |

### AND logic example

Enabling "Keep last 10 versions" and "Older than 30 days" means:

| Version                           | Beyond top 10? | Older than 30 days? | Outcome               |
| --------------------------------- | -------------- | ------------------- | --------------------- |
| Uploaded 5 days ago, in top 10    | No             | No                  | Kept                  |
| Uploaded 5 days ago, position 15  | Yes            | No                  | Kept (not old enough) |
| Uploaded 60 days ago, position 15 | Yes            | Yes                 | **Deleted**           |
| Uploaded 60 days ago, in top 10   | No             | Yes                 | Kept (within top 10)  |

***

## Schedule fields

Schedule fields appear only on cleanup rules. Retention rules have no schedule.

### Timezone

|             |                                                                                    |
| ----------- | ---------------------------------------------------------------------------------- |
| **Default** | UTC                                                                                |
| **Options** | Any Internet Assigned Numbers Authority (IANA) timezone (selectable from dropdown) |

All schedule times are interpreted in the selected timezone. Execution times in the **Lifecycle Rule Executions** tab are shown in UTC.

**Frequency options**

### Daily

| Field   | Valid values |
| ------- | ------------ |
| Hour    | 1–12         |
| Minute  | 0–59         |
| AM / PM | AM or PM     |

### Monthly

| Field        | Valid values                                                                                                                                |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Day of month | 1–31. For months shorter than 31 days, the rule does not execute in that month if the day does not exist (for example, day 31 in February). |
| Hour         | 1–12                                                                                                                                        |
| Minute       | 0–59                                                                                                                                        |
| AM / PM      | AM or PM                                                                                                                                    |

### Yearly

| Field   | Valid values                                     |
| ------- | ------------------------------------------------ |
| Month   | January–December                                 |
| Day     | 1–28 for February, 1–30 or 1–31 for other months |
| Hour    | 1–12                                             |
| Minute  | 0–59                                             |
| AM / PM | AM or PM                                         |

### Custom cron

Accepts a standard 5-field UNIX cron expression: `minute hour day-of-month month day-of-week`.

| Field        | Range                        |
| ------------ | ---------------------------- |
| Minute       | 0–59                         |
| Hour         | 0–23                         |
| Day of month | 1–31                         |
| Month        | 1–12 (or JAN–DEC)            |
| Day of week  | 0–6 (0 = Sunday, or SUN–SAT) |

Common cron examples:

| Expression    | Meaning                           |
| ------------- | --------------------------------- |
| `0 2 * * *`   | Every day at 02:00                |
| `0 2 * * 0`   | Every Sunday at 02:00             |
| `0 2 1 * *`   | First day of every month at 02:00 |
| `0 2 1 1 *`   | 1 January at 02:00                |
| `0 */6 * * *` | Every 6 hours                     |

***

## Execution result statuses

### Version-level statuses (in execution detail view)

| Status               | When it appears     | What it means                                                                                                      |
| -------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **Deleted**          | Scheduled runs only | The version was soft-deleted. It enters the recovery period and can be restored until the recovery window expires. |
| **Would be deleted** | Dry runs only       | The version matched all enabled criteria. No change was made.                                                      |
| **Protected**        | Both                | The version was shielded from deletion. Hover the badge to see the reason.                                         |

**Protected** reasons:

| Reason                          | Source                                                                        |
| ------------------------------- | ----------------------------------------------------------------------------- |
| Matches a retention rule        | A retention rule's pattern filter matches this version                        |
| Actively deployed (Docker only) | Harness CD reports this image version as deployed in at least one environment |

### Rule execution statuses (in execution list)

| Status          | Meaning                                                                              |
| --------------- | ------------------------------------------------------------------------------------ |
| **Success**     | The rule completed and all candidate versions were processed                         |
| **Failed**      | The rule encountered an error; check the execution detail for the specific failure   |
| **In Progress** | The rule is currently running                                                        |
| **Pending**     | The rule has been queued but has not started yet; this is a brief transitional state |

***

## Related pages

* To create a cleanup rule, go to [Create a cleanup rule](https://developer.harness.io/artifact-registry/3.0/lifecycle-management/create-a-cleanup-rule.md).
* To protect specific artifacts, go to [Create a retention rule](https://developer.harness.io/artifact-registry/3.0/lifecycle-management/create-a-retention-rule.md).
* To preview deletions safely, go to [Run a dry run](https://developer.harness.io/artifact-registry/3.0/lifecycle-management/run-a-dry-run.md).
* To review past executions, go to [View rule executions](https://developer.harness.io/artifact-registry/3.0/lifecycle-management/view-rule-executions.md).
* For lifecycle concepts and use cases, go to [Lifecycle rules](https://developer.harness.io/artifact-registry/3.0/concepts/lifecycle-rules.md).

{% @harness-feedback/feedback %}
