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:

  1. In the Administration module, navigate to Artifactory Settings > Retention Policies.
  2. Click Create Retention Policy.
  3. Configure the policy settings.
SettingDescription
Policy NameA descriptive name for the retention policy.
EnabledToggle the policy on or off.
Cron ExpressionSchedule 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/TagsMaximum number of versions or tags to keep (where applicable).
ScopeSelect which repositories the policy applies to, including Federated repositories.
Package TypesFilter by package type (Docker, Maven, npm, and others).
Include/Exclude PatternsPath patterns to include or exclude from cleanup.
Dry RunPreview which artifacts would be deleted without actually removing them.
  1. 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:

  1. Select the retention policy.
  2. Click Run Now to execute the policy immediately.
  3. 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=true

    Where:

    • <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.

AspectBehavior
Deletion events propagateWhen 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 onlyRun 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 membersMembers 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 localThe 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 localA 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.

plusFAQs
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


Did this page help you?