Create Cleanup Policy - Package

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

This topic outlines how to create a cleanup policy. You create a cleanup policy to delete unintended packages in Artifactory.

To create a Package Cleanup Retention policy, follow these steps:

As per the User persona, you can work with the contexts as described below:

  1. In the Retention Policies page, from the Create Policy drop-down list, click Cleanup Policy:

    cleanup-package.gif
  2. In the Create New Cleanup Policy page, select Package.

  3. Configure the following in the Create New Cleanup Policy page:

    Field

    Description

    Policy Name

    Enter a unique and meaningful name for the policy.

    Description

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

    Policy Scope

    Define what should be deleted

    Include Projects / Include All Projects

    Note

    This setting is applicable only at the global level for Platform Admins. It does not appear when creating a policy at the project level. When this setting is visible, it is mandatory.

    Select the projects where you want the policy to apply, or choose Include All Projects to run the policy across all projects on the platform. You can also select Unassigned Repositories to apply the policy to repositories not linked to any projects.

    Package Types

    Select one or more of the package types you want to delete.

    Note

    If a policy includes a repository with retention settings, packages designated for retention may be inadvertently deleted.

    Include Repository Patterns

    • Enter one or more patterns or explicit repository names for the repository selection where you want the cleanup policy to apply. Alternatively, you can select Include All Repositories or specify explicit repository names. At least one pattern or explicit name is required, as only packages in repositories matching these will be deleted.

    • Auto-complete will suggest options based on the project and package type, and both local and federated repositories are supported.

    Note

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

    Note

    Set Patterns: Use wildcards (for example, **) to define Ant-like patterns to include repositories. To learn more, refer to How to use Include/Exclude patterns?

    Exclude Repository Patterns

    Enter one or more patterns or explicit repository names to exclude from the cleanup policy. Auto-complete will suggest options based on the project and package type.

    Note

    Set Patterns: Use wildcards (for example, **) to define Ant-like patterns to exclude repositories. To learn more, refer to How to use Include/Exclude patterns?

    Include Package Name Pattern

    Enter a pattern for a package name or an explicit package name for the cleanup policy, then click Add or select Include All Packages. Only one pattern or explicit name is allowed.

    Note

    Set Patterns: Use wildcards (for example, **) to define Ant-like patterns to include packages. To learn more, refer to How to use Include/Exclude patterns?

    Exclude Package Name

    Enter explicit package names to exclude from the policy and click Add. Only explicit names are accepted and not patterns.

    Policy Conditions

    Define under what conditions the policy finds packages

    Time-based/Version-based

    Do one of the following to define under what conditions the policy finds packages:

    Note

    A policy must include one of the two conditions below:

    • Time-Based: Can be used together

      • Packages Older Than

      • Packages Not Downloaded Since

        Note

        We recommend using the Packages Not Downloaded Since condition to prevent the cleanup of packages that are currently in use.

    • Version Based

      • Number of Latest Versions to Keep.

    • Time-based: This condition can be used as follows:

      • Packages Older Than: Enable checkbox, and apply the number of months/years for the older packages.

        • Deletes packages based on their creation date.

        • Also deletes packages that have never been downloaded.

        • Default: Deletes packages not downloaded for more than 2 years.

      • Packages Not Downloaded Since: Enable checkbox, and apply the number of months/years for the not downloaded packages.

        • Deletes packages based on their last download date.

        • If a package was never downloaded, it deletes based on the creation date if it is older than the specified Not Downloaded Since period.

          For example:

          • Not Downloaded Since: 2 months, artifacts with 0 downloads

          • Package creation date:

            • 1 month ago: Not deleted

            • 2 months ago or older: Deleted

        • Default: Deletes packages not downloaded for more than 2 years.

      • Combined Conditions (Packages Older Than and Packages Not Downloaded Since): When used both conditions together:

        • Deletes packages based on both creation date and last download date.

          Note

          Currently, packages with 0 downloads are not deleted. This will be addressed in future releases.

    • Version-based - Number of Latest Versions To Keep

      Select the number of the latest versions to keep. The cleanup policy will delete all versions that exceed this number, with the latest version always excluded from deleting.

      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, refer to Cleanup Supported Packages.

    Additional Settings

    Cron Expression

    Use a cron expression to set a schedule for policy execution. If left empty, the policy can only be Run Cleanup Policy Manually manually.

    For example, 0 0 2 * * ? executes the policy every day at 02:00 AM. We recommend tuning it to run on off-hours.

    Note

    The minimum interval between policy runs is 6 hours. Scheduling a policy to run at intervals shorter than this will result in an error when saving the policy.

    Max Run Duration

    This setting limits the maximum duration the policy can run when enabled. The maximum allowed duration is 5 hours.

    Note

    The policy stops before the completion of the run if it exceeds the applied run duration. In one run, within this duration, it deletes all or part of your packages depending on the size and number of items. If there are any pending packages to be deleted, they are deleted incrementally in the next scheduled run and the subsequent runs.

    Skip Trash Can

    When enabled, this setting will cause packages to be permanently deleted from Artifactory instance without an option to restore them immediately after the cleanup policy is executed, bypassing the Trash Can repository.

    Note

    If you want deleted items to be transferred to the trash can, you must enable the global Trash Can setting. To learn more, refer to Trash Can Settings.Trash Can Settings

  4. Click Save to save the policy.

    The newly created cleanup policy appears in the Policies list and executes on the scheduled date and time.