Skip to content

Add support for path pattterns in artifactory_package_cleanup_policy #1398

@tkatrichenko

Description

@tkatrichenko

Is your feature request related to a problem? Please describe.
I want to clean packages based on the path where they are stored. It is possible to set a path in the Artifactory UI (couldn't find it in API spec though)

Image

Describe the solution you'd like
Add two optional fields

  • Include Path Patterns - (Optional) Enter one or more folder paths to include in the cleanup policy. Use this option to narrow the policy scope to specific repository paths within the defined repositories.
  • Exclude Path Patterns - (Optional) Enter one or more folder paths to exclude from the cleanup policy. Use this option to include all packages within the defined repositories except for the packages whose path matches the exclude patterns.
resource "artifactory_package_cleanup_policy" "dev_builds_cleanup" {
  key          = "dev-build-cleanup"
  description  = "Delete dev build packages older than 7 days"
  enabled         = true
  cron_expression = "0 0 2 1 * ?"

  search_criteria = {
    package_types = ["generic"]
    repos        = ["**"]

    included_packages         = ["**"]
    included_path_patterns = ["builds/dev/*"]   # requested field
    # excluded_path_patterns = ["..."]                # requested field
    created_before_in_days = 7
  }
}

Describe alternatives you've considered
Setting this setting in UI seems to work as expected

Additional context
Official doc supports path patterns https://docs.jfrog.com/administration/docs/cleanup-policies

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions