Create a Package-Level Cleanup Policy

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

This topic describes how to create a package-level cleanup policy via the JFrog UI. You create a cleanup policy to remove unused packages from Artifactory. For information on how to create a cleanup policy via API, see Create a Package Cleanup Policy API.Create a Package Cleanup Policy API

Note

If a policy is configured to include a repository with retention settings (Tag Retention, Max Unique Tags/Snapshots), there may be a conflict between the policy criteria and the retention setting. In such cases, packages that were intended to be saved by the retention settings might be removed.

To create a cleanup policy:

  1. At the top of the Artifactory screen, click the Administration tab.

  2. If you are a Platform Admin and you want to create a global policy for all projects on the JFrog platform or for multiple projects, ensure that you are in All Projects mode.

  3. In the navigation panel on the left-hand side of the screen, go to Artifactory Settings>Retention Policies. The Retention Policies screen is displayed.

  4. If your version of Artifactory is configured for Cold Storage archiving, you will see two tabs in this screen: Cleanup and Archive. Select Cleanup.

    If your version of Artifactory is not configured for cold storage archiving, the Cleanup tab is selected by default.

    Cleanup_Policies_screen_Global_StopDisable.png
  5. In the upper-right side of the window, click Create Policy. The Create New Cleanup Policy window is displayed.

    Note

    If your version of Artifactory is configured for cold storage archiving, click Create Policy>Cleanup Policy.

    Create_new_cleanup_policy.png
  6. Configure as follows:

    Field

    Description

    Policy Name

    Type a unique and meaningful name to help easily identify the policy.

    Description

    Add information regarding why this policy was created, and details that help users understand its configuration.

    Policy Scope

    Include Projects

    Note

    • This setting is relevant only on the global level, for Platform Admins.

    • If you are creating a policy on the project level, this setting does not appear.

    • When this setting appears, it is mandatory.

    Select the projects on which you want this policy to run, or Include All Projects if you want the policy to run on all projects on the platform. Select Unassigned repositories if you want the policy to run on repositories that are not assigned to any projects.

    Package Types

    Select one or more of the package types you want to remove. This setting is mandatory.

    Include Repositories

    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run and click Add, or select Include All Repositories. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted.

    Auto-complete will provide suggestions based on the project and package type. Local and Federated repos are supported.

    Note

    It is not possible to specify a path within a repository.

    Exclude Repositories

    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy. Auto-complete will provide suggestions based on the project and package type.

    Include Package Name Pattern

    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run and click Add. or select Include All Packages. Only one pattern or explicit name can be entered. This setting is mandatory.

    Exclude Package Name

    Specify explicit package names that you want excluded from the policy and click Add. Only explicit names (and not patterns) are accepted.

    Policy Conditions

    Note

    • A policy must use one of the three settings below.

    • You can use either the Time-Based conditions (Packages Older Than and Packages Not Downloaded Since) or the Version-Based condition (Number of Latest Versions to Keep), but not both.

    • The Time-Based conditions (Packages Older Than and Packages Not Downloaded Since) can be used at the same time.

    • JFrog recommends using the Packages Not Downloaded Since condition to ensure that packages currently in use are not deleted.

    Packages Older Than

    When enabled, removes packages based on when they were created. For example, remove packages that were created more than a year ago. The default value is to remove packages created more than 2 years ago.

    Packages Not Downloaded Since

    When enabled, removes packages based on when they were last downloaded. For example, removes packages that were not downloaded in the past year. The default value is to remove packages that were downloaded more than 2 years ago.

    Note

    If a package was never downloaded, the policy will remove it based only on the age-condition (Packages Older Than).

    Number of Latest Versions to Keep

    Select the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    Note

    • This setting appears only if Version-based is selected.

    • Versions are determined by creation date.

    • Not all package types support this condition. For information on which package types support this condition, click here.

    Additional Settings

    Cron Expression

    Use a cron expression to set a schedule for policy execution. This field is not mandatory, however if you leave it empty the policy can only be triggered manually.

    Example:

    Cron_Expression.png

    Note

    The minimum period between policy runs is 6 hours. If you schedule a policy to run at intervals less than 6 hours, this will cause an error when you try to save the policy.

    Max Run Duration

    When enabled, this setting limits the maximum duration that the policy can run.

    Note

    While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.

    Skip Trash Can

    Enabling this setting results in packages being permanently deleted from Artifactory after the cleanup policy is executed instead of going to the Trash Can repository.

    Note

    The global Trash Can setting must be enabled if you want deleted items to be transferred to the Trash Can. For information on enabling global Trash Can settings, see Trash Can Settings.Trash Can Settings

  7. When you are finished configuring the Cleanup Policy, click Save to save the policy. The newly created policy appears in the Cleanup Policies list. You now have the following options:

    • Perform a Dry Run: Performing a Dry Run enables you to see what items would be deleted, without actually deleting them. For more information see Perform a Dry Run on a Cleanup Policy, JFrog recommends that you first perform a dry run and review its results before you activate a policy.

    • Activate the Cleanup policy: Enable the policy by clicking the Activate toggle next to the policy name. The policy must be activated for it to run according to the automated Schedule Execution or to run it manually. For more information see Activate a Cleanup Policy.