curl : safely delete artifacts from Nexus

Building and deploying a multiple module maven project is easy, but if the process failed in the middle of the modules, it could be quite troublesome to delete the artifacts that had been already uploaded to Nexus.

Though Nexus allow user to delete artifacts through the web UI, it’s tedious and¬†error-prone to locate the artifact/version to be deleted one by one.

Fortunately, Nexus also enabled REST services, so we can compose the URLs, double check carefully and send the request to Nexus via curl.

This is the pattern of the URL that point to a certain arfifact resource in Nexus:


The delete request can be sent with these parameters, I like to suppress the output except HTTP status code, so that it’s easier to check the result of a series of such commands run from shell script.

curl –request DELETE –write “%{http_code} %{url_effective}\\n” –user admin:admin123 –output /dev/null –silent url

PS. this problem is actually addressed by the feature of staged repository, while this feature is available in Nexus Pro edition.