Configure Cleanup Policies for Federated Repositories
Create and run retention policies on Federated repositories while keeping members consistent.
This scenario shows how to configure and run retention policies, also known as cleanup policies, for Federated repositories while preserving consistency across members.
This topic covers the following tasks:
Prerequisites:
- Platform Administrator access
- Retention policies feature enabled on the instance
- At least one Federated repository exists
Use the Platform UI
Create a Retention Policy
Create a retention policy in the Platform UI to define the cleanup criteria for your Federated repositories.
To create a retention policy:
- In the Administration module, navigate to Artifactory Settings > Retention Policies.
- Click Create Retention Policy.
- Configure the policy settings.
| Setting | Description |
|---|---|
| Policy Name | A descriptive name for the retention policy. |
| Enabled | Toggle the policy on or off. |
| Cron Expression | Schedule for automatic execution (for example, 0 0 2 * * ? for 2:00 AM daily). |
| Duration (days) | Artifacts older than this number of days are candidates for cleanup. |
| Max Unique Versions/Tags | Maximum number of versions or tags to keep (where applicable). |
| Scope | Select which repositories the policy applies to, including Federated repositories. |
| Package Types | Filter by package type (Docker, Maven, npm, and others). |
| Include/Exclude Patterns | Path patterns to include or exclude from cleanup. |
| Dry Run | Preview which artifacts would be deleted without actually removing them. |
- Click Save.
Execute a Retention Policy
After creating a retention policy, execute it to remove artifacts that meet the retention criteria.
To execute a retention policy:
- Select the retention policy.
- Click Run Now to execute the policy immediately.
- Monitor the execution in the policy's run history.
Tip
Always run a Dry Run first to review which artifacts will be removed before executing a retention policy on Federated repositories.
Use the REST API
Manage retention policies using the Retention Policies REST APIs.
To manage retention policies using the REST API:
-
Create a retention policy:
POST /artifactory/api/retention/policies Content-Type: application/json -
Execute a retention policy:
POST /artifactory/api/retention/policies/<POLICY_NAME>/execute -
Dry run a retention policy:
POST /artifactory/api/retention/policies/<POLICY_NAME>/execute?dryRun=trueWhere:
<POLICY_NAME>: The name of the retention policy to execute
For example:
POST /artifactory/api/retention/policies/docker-cleanup-30d/execute
Federation Behavior
The following table describes how cleanup policy actions behave across Federation members. Because deletions propagate to every member, they are irreversible unless the Trash Can is enabled on the executing member.
| Aspect | Behavior |
|---|---|
| Deletion events propagate | When a retention policy deletes artifacts from a Federated repository, the deletion events propagate to all Federation members. The artifacts are removed from all members, not just the one where the policy was executed. |
| Execute on one member only | Run retention policies from a single Federation member to avoid conflicting deletions. If the same retention policy runs on multiple members simultaneously, duplicate deletion events may be generated. |
| Receiving-only members | Members configured in receiving-only mode receive the propagated deletion events. They don't execute retention policies locally and can't initiate deletions that propagate outward. |
| Retention policies are local | The retention policy configuration itself isn't synchronized across Federation members. Each member maintains its own policy definitions. Only the resulting deletion events propagate. |
| Dry Run is local | A dry run shows only the artifacts that exist on the member where it is executed. Artifacts that exist on other members but haven't yet synchronized aren't included. |
Warning
Deleting artifacts through a retention policy is irreversible. Once deletion events propagate to all Federation members, the artifacts cannot be recovered, unless the Trash Can is enabled on the executing member.
Frequently Asked Questions
This section provides answers to frequently asked questions.
FAQs
Q: How do I create a retention policy for Federated repositories?
A: In the Administration module, go to Artifactory Settings > Retention Policies, click Create Retention Policy, configure the settings, and save. See Create a Retention Policy for the full procedure.
Q: Do deletion events from a retention policy propagate to all Federation members?
A: Yes. When a retention policy deletes artifacts from a Federated repository, the deletion events propagate to every Federation member, not just the one where the policy ran.
Q: Should I run the same retention policy on multiple Federation members?
A: No. Run retention policies from a single Federation member to avoid conflicting deletions — running the same policy on multiple members at once can generate duplicate deletion events.
Q: Can I preview what a retention policy will delete before running it?
A: Yes. Always run a Dry Run first to review which artifacts a retention policy would remove before executing it on Federated repositories.
Q: Are retention policy configurations synchronized across Federation members?
A: No. Retention policy configurations are local — each member maintains its own policy definitions. Only the resulting deletion events propagate across the Federation.
Related Topics
Updated about 7 hours ago
