Create Cleanup Policy - Build

JFrog Platform Administration Documentation

Content Type
Administration / Platform

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

Removing a build deletes build entity, build-info and build artifacts. To exclude build artifacts from deletion, uncheck Delete Build Artifacts checkbox under Settings (It is checked by default).

To create a Build 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 Build.

  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.

    Include Build Patterns/Include All Builds

    From the drop-down, select the build or choose Include All Builds to run the policy across all builds.

    Note

    Specify builds to include by explicit name. (or) Use wildcards at the end to match any suffix. For example, buildxyz* includes all builds starting with buildxyz.

    Using * as a wildcard at the start of the pattern isn't allowed. For example, *buildxyz is invalid.

    Policy Conditions

    Define under what conditions the policy finds builds

    Builds older than

    Specify the number of days/weeks/months/years for the older builds.

    • Deletes builds based on their creation date.

    Note

    A day in this context is a 24-hour period from the moment the policy is executed. Other units are considered as follows:

    • 1 week = 7 days

    • 1 month = 30 days

    • 1 year = 365 days

    The system will convert them to appropriate time unit if the matching value is entered. For example, if you enter 7 days, the system changes it to 1 Week.

    Settings

    Delete Build Artifacts

    Deletes the artifacts associated with the build.

    Note

    This setting is enabled by default. Disable the checkbox to exclude build artifacts from deletion.

    When determining which artifacts will be deleted with your build, the following rules apply:

    • Artifact Resolution from Build-Info: If the full repository path of the build artifacts exists in the build-info, the artifacts will be resolved from their original location where the build was published via the CLI.

      Note

      This behavior is available from version 7.106.1.

    • Older Builds: If the build artifacts do not have an available full repository path, they will be resolved using their SHA and associated properties: build.name, build.number, and build.timestamp.

      Note

      • If the artifacts were promoted or copied to another target, they will also be deleted from those locations.

      • For certain build integration tools (for example, Jenkins) that may create inconsistent build.timestamp (compared to the build-info's started field), the deletion process will check if the same build name and build number exist in another project.

        • If found, the artifacts will not be deleted.

        • If not found, the artifacts will be deleted based on their SHA and properties (build.name, build.number).

        Always use a recent version of JFrog CLI as your build client for optimal results. For more information and to download the latest version, refer to CLI Documentation and Build Integration.Build Integration

    Cron Expression

    A cron expression is a string comprised of five or six fields separated by spaces. Each field represents a different unit of time, which collectively define the schedule for policy execution. The standard format is as follows:

    * * * * * *     (Seconds - Optional)
    | | | | | |
    | | | | | +---- Day of the week (0 - 6) (Sunday=0)
    | | | | +------ Month (1 - 12)
    | | | +-------- Day of the month (1 - 31)
    | | +---------- Hour (0 - 23)
    | +------------ Minute (0 - 59)
    +-------------- Second (0 - 59) (Optional)

    Note

    This cron expression must follow the Quartz scheduler format as used in the CronTrigger class. It differs from the standard Unix cron format. For example, Quartz supports a sixth optional field for seconds and uses ? for non-specific values. Refer to the Quartz documentation for more details: Quartz Cron Expression Format

    Example Cron Expression

    To illustrate how to construct a cron expression, consider the example below:

    Expression: 0 0 2 * * ?

    • 0 - At second 0

    • 0 - At minute 0

    • 2 - At hour 2 (2:00 AM)

    • * - Every day of the month

    • * - Every month

    • ? - No specific value for the day of the week

    This expression schedules the policy to run every day at 2:00 AM.

    Guidelines for Scheduling

    • Run Interval: The minimum interval between policy executions is 6 hours. If you attempt to set a cron expression that results in a runtime shorter than this duration, you will encounter an error when saving the configuration.

    • Off-Hours Scheduling: It is recommended to tune your cron expression so that policies run during off-hours. This helps to reduce the impact on system performance during peak usage times.

    Leaving the Cron Expression Empty: If you leave the cron expression empty, you can only Run Smart Archiving Policy Manually manually. This means that there will be no automatic scheduling and the policy will not run unless you initiate it.

    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 builds depending on the size and number of items. If there are any pending builds 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 builds 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.