Open rpocase opened 5 years ago
Worth noting that the approach above only works for structures where artifacts are stored in version folders. The simple-default layout proposes versioning artifacts directly without the version folder layer. In this context, count_based_retention
only works if you produce a single type of artifact. You can certainly change your posting structure, but that typically has far reaching ramifications.
I realized this is an older issue. Replying in case this could help someone else.
It possible to use native aql to do what you desire
terms = [ { "stat.downloaded": { "$before": "1mo" }},
{ "@build.correlation_ids": { "$nmatch": "*" }},
{ "name": { "$match": "manifest.json" }},
{ "path": { "$nmatch": "*/latest" }}
]
purgeable = artifactory.filter(terms=terms, depth=None, item_type="file")
return purgeable
A predominant use case internally is generic repositories that have multiple types of artifacts within a given folder. E.g.
Count based retention works great here except in cases where I may have artifacts that should be kept regardless of age (e.g., artifacts containing metadata that can't be expressed well in properties).
Using the versions API, we could be more intelligent about keeping the latest set of versioned artifacts from particular repositories (or particular folders under a given repository).
E.g.
My workaround for the time being is like the below. This combines
time_based_retention
andcount_based_retention
while allowing for providing extra_aql to handle filtering. This still requires me to make structural changes to how I post files that should be included (e.g. they go in a separate tree that gets filtered out by AQL).