0

I don't want to have to select each package one by one and delete the version, this is incredibly tedious (there could be a 100 packages, but even 20 is painful using the UI).

What is the easiest way to achieve this?

I wish I could just do this from the Advanced Search from Browse, but there's no way I can see to multi-select and Delete isn't an option until I go to the folder tree view.

A Task would be nice, but all the tasks I see don't have filtering

Novaterata
  • 4,356
  • 3
  • 29
  • 51
  • For context, I'm talking about a snapshot here – Novaterata Aug 04 '21 at 12:45
  • 1
    Disclaimer: the following link is a project by a colleague of mine strongly suggested by other groovy script I wrote and shared with him but cannot currently share publicly. Studying it will hopefully give you some ideas. It's basically using the API to cleanup nexus repositories with various parameter as entry points. https://github.com/benDeMtp/NexusHouseKeeper – Zeitounator Aug 06 '21 at 20:03
  • 1
    @Zeitounator thanks, I'll look into it! Crazy this isn't built-in to the UI – Novaterata Aug 07 '21 at 02:39

1 Answers1

2

You can achieve this by using the Cleanup Policies Feature.

Here's how:

Create a cleanup policy:

Goto Administration->Repository->Cleanup Policies and click:

- Create Cleanup Policy

In cleanup criteria deselect all and then select:

- Asset Name Matcher

In the textfield add a regex to suit your needs. For example to clear the repo completely:

.*

For example to clear the repo of maven package "cert-cvc" version 1.4.9:

.*cert-cvc-1.4.9.*

Attach the cleanup policy to your repository

Edit your Repository and add the cleanup policy you just created.

Goto Administration->System->Tasks

 - Select the Cleanup service
 - Click Run

It will cleanup the repository immediately.

Once complete don't forget to remove the cleanup policy if you don't want it to kick in again at the next scheduled run.

  • How does version come into it? – Novaterata Mar 20 '22 at 14:17
  • 1
    Just add the version to the asset name matcher. Something like: .*1.4.9.* Or include the name too: .*cert-cvc-1.4.9.* Then click preview to check if the packages you want to remove are included in the preview list. (I've updated the answer with an example) – Jason Separovic Mar 20 '22 at 22:18
  • @Novaterata did you get it to work? if so do you mind accepting the answer? Cheers – Jason Separovic Sep 26 '22 at 20:11