We have an Artifactory server that is using 220Gb - with the libs-snapshots-local
repository utilising 98% of that storage.
When we looked at the configuration for the repository we noted that Maven snapshot behaviour was set to: unique
and that the Max Unique Snapshots value was 0
.
We changed the Max Unique Snapshots value to 5.
This seems to work when we are still working on the Snapshot, however if we no longer deploy to the snapshot (a release has been made) then it doesn't delete any of these files.
As an example: we have the following in the Snapshots repository:
com/company/some/app/1.23-SNAPSHOT/.. (50+ artifacts)
com/company/some/app/1.24-SNAPSHOT/.. (5 artifacts)
Artifactory keeps the current SNAPSHOT directory ( 1.24-SNAPSHOT
) at a max of 5 artifacts, however the number of artifacts in the 1.23-SNAPSHOT
directory never decreases.
It seems that Artifactory uses the deployment of an artifact to trigger the cleanup check - Thus if you're no longer deploying to that artifact, then no clean up will be done?
How do we get Artifactory to start deleting the surplus artifacts in the 1.23-SNAPSHOT
folder?
You are right, deployment of a new snapshot is the trigger for deletion of the old ones. Since your 1.23 artifacts explosion is the leftover of the previous (mis)configuration, you're good from now on.
The simplest way to delete the old snapshots is just to deploy another (even dummy) snapshot into 1.23. It will trigger the cleanup.
Another idea might be creating another snapshots repo and moving the last 5 snapshots of 1.23 to it. Then you can safely delete the 1.23 folder and move it from the temporary repo back in.
All those are valid choices for cleaning up one or couple of version, but they won't scale. If you have a lot of versions to cleanup I would recommend writing a simple execution user plugin.
You just get the children of a version directory and delete everything except the few you want to leave.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With