ARTIFACTORY: How to Target Specific Subfolders in Artifactory Retention Policies Using Properties

Products
Frog_Artifactory
Content Type
Administration_Platform
AuthorFullName__c
Sara Ngo
articleNumber
000006885
FirstPublishedDate
2026-03-19T08:45:59Z
lastModifiedDate
2026-03-19

ARTIFACTORY: How to Target Specific Subfolders in Artifactory Retention Policies Using Properties

Introduction 
Administrators often need to create Retention Policies that target artifacts residing only within specific subfolders of a repository. However, the current native Retention Policy interface allows scoping by Repository or Project, but does not support defining scope by specific internal subfolder paths.

Attempting to manage cleanup for specific project paths or folder structures without this feature can be challenging.


This article will walk you through a property-based workaround that allows you to target specific subfolders for cleanup by "tagging" the artifacts you wish to remove.



Resolution
To achieve subfolder-specific cleanup, we use a two-step logic: Tag and Delete. Instead of telling the policy where to look (which isn't supported), we label the artifacts so the policy knows what to target.

Step-by-Step Instructions

Phase 1: Identify and Tag Target Artifacts

First, you must apply a specific property (e.g., cleanup=true) to the artifacts located in the desired subfolder. This can be done using the JFrog CLI or the REST API.
  1. Define your criteria: Determine which subfolder path you want to target (e.g., example-repo-local/test/*).
  2. Apply the Property: Use the JFrog CLI to set a property on all items within that path.
    • Command example
      jf rt set-props "example-repo-local/test/*" "cleanup=true"
      Note: You can automate this step using a CI/CD pipeline or a cron job to ensure new artifacts in this folder are always tagged.
Phase 2: Configure the Retention Policy

Once the artifacts are tagged, configure the Retention Policy to look for that specific property.
  1. Log into the JFrog Platform UI as an Administrator.
  2. Navigate to Administration > Artifactory Settings > Retention Policies.
  3. Click Create Policy.
  4. Select the repository containing your target subfolders in Include Repository Patterns.
  5. Policy Conditions:
    • Set your time-based criteria (e.g., artifacts older than 30 days).
    • Locate the Property section.
    • Add a condition: Key: cleanup, Value: true.
  6. Save and then perform a Dry Run to verify that only the tagged artifacts in your subfolder are selected. 


Conclusion 
By marking specific subfolders with a custom property, you can effectively bypass the current limitation regarding path-based Retention Policies. The Retention Policy will scan the entire repository but will only act on items possessing the specific tag you applied.