Visit my.sonatype.com for documentation on Nexus Repository version 2.
Nexus Repository 2.4 and newer
A scheduled task has been added which can remove staging repositories that 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 Repository 2.3 and older
Nexus Repository 2 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:
{
"data":{
"stagedRepositoryIds":[
"abc-001"
],
"description":"Releasing abc 1.2.3."
}
}
The response for the GET is a bit more involved, but it is documented in Nexus Repository 2. 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:
{
"data":[
{
"profileId":"12c81eb4fee3774f",
"profileName":"abc",
"profileType":"repository",
"repositoryId":"abc-001",
"repositoryName":"abc-001 (u:deployment, a:127.0.0.1)",
"type":"closed",
"policy":"release",
"userId":"deployment",
"userAgent":"Apache-Maven/3.0.4 (Java 1.6.0_37; Mac OS X 10.8.2)",
"ipAddress":"127.0.0.1",
"repositoryURI":"http://localhost:8081/nexus/content/repositories/abc-001",
"createdDate":"Mon Nov 19 16:52:33 CST 2012",
"createdTimestamp":1353365553825,
"closedDate":"Mon Nov 19 16:52:50 CST 2012",
"closedTimestamp":1353365570059,
"description":"",
"provider":"maven2",
"releaseRepositoryId":"releases",
"releaseRepositoryName":"Releases"
}
]
}
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
2 Comments
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.
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.