Visit my.sonatype.com for documentation on Nexus Repository version 2.
In general, it is OK to directly add/remove artifacts from a repository's local storage directory on disk.
There are a few things to be aware of when doing this:
- Adding and removing artifacts from local storage may leave maven-metadata.xml files in an inconsistent state.
- Changes made directly to local storage will not be reflected in search indexes.
- If you are running Nexus Repository 2.4 or later, the prefix files used by automatic routing may need to be updated.
To do this through the UI right click on the repository and select "rebuild metadata", followed by "repair indexes". The automatic routing can be updated by restarting the server.
These actions can also be scripted via the Nexus Repository 2 REST API. Here's how to do this using curl:
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/repositories/<repo-id>/routing
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/metadata/repositories/<repo-id>/content/path/to/folder/
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/data_index/repositories/<repo-id>/content
Note: Substitute "<repo-id>" in the commands above with the repository ID of the repository you want the commands to be run against, as in "releases".
Note: It is not possible to trigger content path-specific search index ( data_index ) rebuild
7 Comments
Could you please also share permissions and roles needed for above operations?
Is it possible to do repository based restrictions?
Most of these tasks cannot be assigned privileges on a per repository basis, so it is best to just use an admin account.
Thanks for your answers,
Concerning the 3 REST API uri you mention above, I don't know if I can also complete the first and the third with the path to the folder I want to delete, as the second, to have this :
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/repositories/<repo-id>/routing/path/to/folder
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/metadata/repositories/<repo-id>/content/path/to/folder/
curl -v -u userID:password -X DELETE http://localhost:8081/nexus/service/local/data_index/repositories/<repo-id>/content/path/to/folder
Thanks again.
Best regards,
WOGNIN
Only the /service/local/metadata/repositories endpoint should have a path after it, the others operate on a per repository level.
Thanks for your advices,
When I use the three mentionned REST url, the artifacts are deleted but the remain in the search result.
It means that the metada or index are not deleted.
However my pupose is to delete everything including index and metadata.
Have I misunderstood anything ?
There's an issue around deletion, for now you'll need to run "repair indexes" to have deleted items removed from the search index: https://issues.sonatype.org/browse/NEXUS-9381
We are closing this article for comments.
If you have a support license, please contact us by submitting a support ticket.
If you do not have a support license, please use our Nexus Users List or our other free support resources.