Overview
Automate artifact retention and cleanup with policy-based lifecycle rules that cut storage costs, enforce compliance, and keep registries manageable.
Every build pipeline produces artifacts. Over weeks and months, registries accumulate thousands of versions that no one downloads, deploys, or references again. Storage costs rise, search results become noisy, and compliance audits grow harder when stale artifacts sit alongside production releases. Lifecycle rules solve this by automating what to keep and what to remove, so your registries stay lean without manual intervention.
Harness Artifacts provides two lifecycle rule types that work together: cleanup rules that delete stale artifact versions on a schedule, and retention rules that protect critical versions from any form of deletion. Lifecycle rules combine multiple criteria, support regex-based pattern filters across all package types, and automatically protect Docker images that are actively deployed through Harness CD.
Why lifecycle management matters
Artifact registries grow silently. A team running 20 builds a day generates over 7,000 artifact versions in a year, and most are never used after the initial integration test. Without automated lifecycle management:
Storage costs compound: Cloud storage is billed per gigabyte. Container images, Maven JARs, npm packages, and other artifacts add up quickly, and stale versions consume the same space as active ones.
Compliance becomes harder: Regulated industries require audit-ready control over what data is retained, for how long, and when it is removed. Manual cleanup does not provide the governance trail that auditors expect.
Registry usability degrades: Long artifact lists slow down searches, make it harder to find the right version, and increase the risk of deploying an outdated build.
Security exposure grows: Older artifact versions may contain known vulnerabilities. Keeping them accessible increases the attack surface.
Lifecycle rules address all of these by applying consistent, repeatable policies across your registries, with a full audit trail of every action taken.
Rule types
Harness supports two lifecycle rule types:
Cleanup rule: Identifies artifact versions that match your deletion criteria and soft-deletes them on a cron schedule (daily, monthly, yearly, or custom). Deleted artifacts remain recoverable during the recovery period configured at the account level. To create one, go to Create a cleanup rule.
Retention rule: Protects matching artifacts from all deletion types, including cleanup rules, manual soft delete, and manual hard delete. Retention rules have no schedule; they are evaluated automatically whenever a cleanup rule runs, and they always take priority. To create one, go to Create a retention rule.
You can combine both types on the same registry. For example, a cleanup rule removes staging builds older than 30 days while a retention rule ensures latest and production-* tags are never touched.
How lifecycle rules work
A lifecycle rule is a reusable policy that you create at the account, organization, or project level and attach to one or more registries. Rules do nothing until you attach them to a registry.
When a cleanup rule executes on schedule, the system:
Fetches all registries attached to the rule.
Scans artifact versions in each registry against the cleanup criteria.
For Docker registries, queries Harness CD and marks versions that are actively deployed as PROTECTED.
Evaluates all applicable retention rules and removes protected artifacts from the candidate set.
Deletes remaining candidates that satisfy all enabled criteria.
Records the execution result with a complete audit trail.
Deployment-aware protection for Docker
For Docker registries, Harness adds an automatic safety net. When a cleanup rule runs, the system queries Harness CD and marks every Docker image version that is actively deployed in any environment as PROTECTED. Those versions are skipped regardless of whether they match the cleanup criteria.
This protection is automatic. You do not need to configure a retention rule to keep deployed Docker images safe.
Manage rules
To view, create, and manage lifecycle rules, go to Artifact Registry > Registries Settings > Lifecycle Rules. The summary cards at the top of the page show total storage saved, artifacts cleaned, and executions in the last 30 days.

Enable or disable a rule
Each cleanup rule has a toggle in the rules list. Use it to pause a rule without deleting its configuration. A disabled rule retains its registry attachments but does not execute on schedule. Toggle it back on to resume scheduled executions.
Edit or delete a rule
Select the More icon (⋮) on a rule row to access Edit, Delete, and (for cleanup rules) Dry run. Deleting a rule removes it and all its registry attachments. Artifacts that were soft-deleted by previous executions remain recoverable for the configured recovery period.
Filter the rules list
Use the toolbar filters to narrow the view:
Rule Type: Cleanup Rule or Retention Rule.
Registries: Filter by specific registry.
Package Types: Filter by package format.
Use rules from a parent scope
Lifecycle rules created at a parent scope (account or organization) can apply at child scopes (organization or project). By default, the rules list shows rules created at the current scope and parent-scope rules that are already applied. Select Show policies from parent scope to see parent-scope rules that are not yet applied, then attach them to registries at the current scope.
When you use a rule from a parent scope, you can only change which registries the rule applies to. Criteria, schedule, and other settings remain controlled by the parent scope. The inheritance icon in the table indicates which rules come from a parent scope.
Execution visibility follows a top-down model:
A parent scope can view execution entries from all child scopes. Select Show items from child scope on the execution detail to expand the view.
A child scope can only view entries from its own scope, even when the rule is owned by a parent scope.
Notifications
You can receive alerts when lifecycle rule executions complete. Artifact Registry supports two notification events:
Lifecycle Policy Execution Completed: Triggers when a scheduled cleanup rule finishes.
Lifecycle Policy Dry Run Execution Completed: Triggers when a dry run finishes.
Configure notification rules in the Harness platform notification settings.
Audit trail
Harness records lifecycle rule create, update, and delete operations in the platform Audit Trail. Each audit event identifies who made the change and provides the rule configuration details. Updates include configuration changes and changes to a cleanup rule's enabled state.
Next steps
To automate artifact deletion, go to Create a cleanup rule.
To protect critical artifacts from deletion, go to Create a retention rule.
To validate a rule before it runs, go to Run a dry run.
To review past executions, go to View rule executions.
To understand lifecycle concepts in depth, go to Lifecycle rules.
Last updated
Was this helpful?