-
Notifications
You must be signed in to change notification settings - Fork 122
Add support for version pattterns in artifactory_package_cleanup_policy #1384
Description
Is your feature request related to a problem? Please describe.
The JFrog UI's Cleanup Policies support Include Package Version Pattern and Exclude Package Version Pattern fields, allowing policies to target specific version strings (e.g. *dev* to match dev pre-releases). The artifactory_package_cleanup_policy Terraform resource does not expose these fields, making it impossible to replicate this configuration in code.
We need to clean up some dev package versions (e.g. 0.10.0.dev+<git_hash>) from PyPI repositories on a schedule without affecting stable release versions.
Describe the solution you'd like
Add two optional fields to the artifactory_package_cleanup_policy resource schema:
resource "artifactory_package_cleanup_policy" "dev_release_cleanup" {
key = "dev-release-cleanup"
description = "Delete dev package versions not downloaded in 30 days"
package_type = "pypi"
repos = ["**"]
included_packages = ["my-packages"]
included_version_patterns = ["*dev*"] # requested field
# excluded_version_patterns = ["..."] # requested field
enabled = true
cron_expression = "0 0 2 1 * ?"
}| Field | Type | Description |
|---|---|---|
included_version_patterns |
[]string |
Glob patterns — only matching versions are eligible for cleanup |
excluded_version_patterns |
[]string |
Glob patterns — matching versions are excluded from cleanup |
These map to includedVersionPatterns / excludedVersionPatterns in the JFrog Platform cleanup policy REST API, which already supports them (visible in the UI under Administration > Cleanup Policies).
Describe alternatives you've considered
- Creating the policy entirely via the JFrog UI (current workaround — not version-controlled)
- Using
artifactory_package_cleanup_policywithout version filtering (unsafe — would delete stable release versions) - We're considering asking the devs to use Github Actions that upload the package to delete
devpackages upon PR merge/close. But if we can standardize around a policy for patterns likercordevetc. it would be nice to have this vs adding script code everywhere. - We could have a new repo for dev packages only and clear them out on a cadence that works with that team like 30 days, etc. But I'm hoping to keep changes minimal on dev teams if possible.
Additional Context
I used Claude Code to generate this issue text (proofread and added my own notes, cleaned things up). My apologies for any weird AI-ness. Thank you!