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

Yes, 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 though.

First, adding and removing artifacts from local storage may leave maven-metadata.xml files in an inconsistent state.  Second, changes made directly to local storage will not be reflected in search indexes.  Finally, if you are running Nexus 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 be also be scripted via the Nexus 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".

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.
Powered by Zendesk