Automatically dropping old staging repositories


If you make heavy use of Nexus Professional's staging feature you may find that over time you accumulate staging repositories, and that some of these need to be automatically dropped.

Nexus 2.4 and newer

 A scheduled task has been added which can remove staging repositories which are in open, closed, or promoted states and have been inactive for a specified number of days. See the Scheduled Task documentation for more information.

Nexus 2.3 and older

Nexus doesn't have direct support for doing this, but it's quite easy to implement this yourself using the REST API.  Here are the required endpoints:

  • List Staging Repositories:  GET /service/local/staging/profile_repositories/<profile-id>
  • Release a Staging Repository: POST /service/local/staging/bulk/promote
  • Close a Staging Repository: POST /service/local/staging/bulk/drop

Just make a call to list the repositories, look at the state and timestamp/date, and take appropriate action.

The payload format for the two POST's requests is quite simple:

      "description":"Releasing abc 1.2.3."

The response for the GET is a bit more involved, but it is documented in Nexus. Just go to "administration/plugin console" and click on the staging plugin.  There will be a documentation link in the bottom panel in the UI.

Here's a sample output:

         "repositoryName":"abc-001 (u:deployment, a:",
         "userAgent":"Apache-Maven/3.0.4 (Java 1.6.0_37; Mac OS X 10.8.2)",
         "createdDate":"Mon Nov 19 16:52:33 CST 2012",
         "closedDate":"Mon Nov 19 16:52:50 CST 2012",


Examples using curl:

1) List staging repositories

curl -u admin:admin123 -H "Accept: application/json" http://localhost:8081/nexus/service/local/staging/profile_repositories

2) Release a staging repository

curl -u admin:admin123 -H "Accept: application/json" -H "Content-Type: application/json" -d '{"data":{"stagedRepositoryIds":["abc-001"],"description":"Releasing core 1.2.3."}}' http://localhost:8081/nexus/service/local/staging/bulk/promote

3) Drop a staging repository

curl -u admin:admin123 -H "Accept: application/json" -H "Content-Type: application/json" -d '{"data":{"stagedRepositoryIds":["abc-001"],"description":"Releasing core 1.2.3."}}' http://localhost:8081/nexus/service/local/staging/bulk/drop


Have more questions? Submit a request


  • 0
    David Hladky

    Thank you for adding this feature into the system. However the problem with the task is  there is no way to narrow the task into a specific profile. We still can use the REST API and we will, however it is less elegant than using the scheduled task.

  • 0
    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.