1

I've recently set up NXRM3.13.0-01 and have been building an artifact snapshot to the maven-snapshots repository. The integration with my local maven build seems ok. It reads from Nexus, deploys the latest timestamped artifact when built and gets the latest timestamped snapshot when told to. I have a Maven - Delete Snapshot task configured to remove snapshots with the following configuration:

Repositories: All Repositories
Snapshot retention (days): 30
Minimum snapshot count: 3
Remove if released: yes
Grace period after release (days): 7

When this task runs though, it does not remove anything from the snapshot repository. I also ran a Compact Blob Store task after as per the docs in case reclaiming the disk space was required but to no avail. From the logs, I can see that the two versions 1.0 and 5.8.01 are identified as candidates. However, no artifacts are purged. In the logs I can see the following. It finds no qualifying artifacts for removal:

2018-09-13 10:12:49,423+0000 INFO  [qtp1041814774-1123]  admin org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Mark Snapshots for Deletion' [repository.maven.remove-snapshots] runNow
2018-09-13 10:12:49,424+0000 INFO  [qtp1041814774-1123]  admin org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Mark Snapshots for Deletion' [repository.maven.remove-snapshots] state change WAITING -> RUNNING
2018-09-13 10:12:49,459+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.tasks.RemoveSnapshotsTask - Task log: /nexus-data/log/tasks/repository.maven.remove-snapshots-20180913101249447.log
2018-09-13 10:12:49,460+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.tasks.RemoveSnapshotsTask - Executing removal of snapshots on repository 'maven-snapshots'
2018-09-13 10:12:49,496+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Beginning snapshot removal on repository 'maven-snapshots' with configuration: org.sonatype.nexus.repository.maven.tasks.RemoveSnapshotsConfig(minimumRetained:3, snapshotRetentionDays:30, removeIfReleased:true, gracePeriod:7)
2018-09-13 10:12:49,497+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Begin processing snapshots in repository 'maven-snapshots'
2018-09-13 10:12:49,504+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Found 2 snapshot GAVs to analyze
2018-09-13 10:12:49,516+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - ---- Searching for GAVS with snapshots that qualify for deletion on repository 'maven-snapshots' ----
2018-09-13 10:12:49,517+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Elapsed time: 12.14 ms, deleted 0 components from 0 distinct GAVs
2018-09-13 10:12:49,518+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Finished processing snapshots with more than 3 versions created before 2018-08-14T10:12:49.517Z
2018-09-13 10:12:49,518+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Updating metadata on repository 'maven-snapshots'
2018-09-13 10:12:49,519+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.repository.maven.internal.RemoveSnapshotsFacetImpl - Completed snapshot removal on repository 'maven-snapshots'
2018-09-13 10:12:49,520+0000 INFO  [quartz-5-thread-20]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Mark Snapshots for Deletion' [repository.maven.remove-snapshots] state change RUNNING -> WAITING (OK)

The snapshot repository is as follows. My assumption would be that the top two for v5.8.01-SNAPSHOT would be removed and that the lower two would be kept based on the task config:

Nexus Artifact

My questions are:

  1. Have I missed something?
  2. What can I do to get the desired behaviour?
Dec Clarke
  • 53
  • 2
  • 8
  • 1
    You have configured to keep `Minimum snapshot count: 3` ...I would suggest to change that to `0` and your retention days sounds very long..usually I configure Nexus with 7 days max...and no grace period...cause after 7 days a SNAPSHOT's has been replaced by several others..so no need to have those old ones...Apart from that is there a good reason why you use version like `5.8.01`? Why not using `5.8.1` simply? BTW: If you see the time stamp it's from 11.9.2018 which means only two days old so I wouldn't expected to be removed ? – khmarbaise Sep 13 '18 at 12:51
  • Versioning is the way it is unfortunately. That said, I am a fool. The retention date was the problem. Staring me right in the face. I tweaked it there to be 0 and it resolved it. Been staring at it too long. Thank you! – Dec Clarke Sep 13 '18 at 12:59
  • No problem. Happens from time to time...welcome to the club ;-) – khmarbaise Sep 13 '18 at 13:03

3 Answers3

3

Timestamped snapshots are not deleted when a snapshot version is set to be kept, even if the policy is correctly configured. Realising that I had to write my own code that could delete the timestamped snapshots in Nexus 3, you can find it under https://gist.github.com/dwamara/506a51483549eb1c8f90eb88c82e17a6. IT works perfectly and I was so able to decrease the size of the snapshots from 1.4 TB to 200GB. Don't forget to compact the blobstore when finished.

Daniel W.
  • 71
  • 7
  • While not directly related to your answer, I'd like to add, that in order to configure any cleanup policy, (1) one has to set up that policy in `Cleanup Policies`, (2) **add it** to the repository it is supposed to work on (in `Repositories`) and - once done - (3) manually execute the Cleanup task (in `Tasks`) and (4) then run a task called `Compact ... blob store` (which you mentioned in your answer). – Igor May 24 '20 at 22:55
0

The artifacts were within the retention threshold. Setting the retention to zero allowed them to be removed as expected. Thanks @khmarbaise

Dec Clarke
  • 53
  • 2
  • 8
0

Thanks @khmarbaise, your advice works for Nexus2.x too, but there are things that anybody should be care for:

  • Set Minimum snapshot count: 0 and Snapshot retention (days): 7 means that if no snapshots pushed in recent 7 days, there would be no snapshots in that artifact folder.
  • If Remove if released is checked, the artifact folder would be delete from snapshot repo when a release version got released

  • My Nexus2.x example

NOZUONOHIGH
  • 1,892
  • 1
  • 20
  • 20