Can I directly update artifacts in Nexus Repository 2 local storage on disk?

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:

  1. Adding and removing artifacts from local storage may leave maven-metadata.xml files in an inconsistent state. 
  2. Changes made directly to local storage will not be reflected in search indexes. 
  3. 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

Have more questions? Submit a request

7 Comments

  • 0
    Avatar
    Emil Genchev

    Could you please also share permissions and roles needed for above operations?

    Is it possible to do repository based restrictions?

  • 0
    Avatar
    Rich Seddon

    Most of these tasks cannot be assigned privileges on a per repository basis, so it is best to just use an admin account.

  • 0
    Avatar
    wognin a

    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

  • 0
    Avatar
    Rich Seddon

    Only the /service/local/metadata/repositories endpoint should have a path after it, the others operate on a per repository level.

  • 0
    Avatar
    wognin a

    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 ?

  • 0
    Avatar
    Rich Seddon

    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

  • 0
    Avatar
    Peter Lynch

    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.

Article is closed for comments.