Visit my.sonatype.com for documentation on Nexus Repository version 2.
To create a new staging repository via REST API you can makeĀ a POST request to /service/local/staging/profiles/<profile-id>/start
:
For example:
curl -X POST -d @file.xml -u admin:admin123 -H "Content-Type:application/xml" -v http://localhost:8081/nexus/service/local/staging/profiles/13500f3f63e468f7/start
The payload in "file.xml" looks like this:
<promoteRequest> <data> <description>some description here</description> </data> </promoteRequest>
Note: The staging profile ID can be found in the staging profile's configuration in the UI.
The response contains the repository ID just created:
<promoteResponse> <data> <stagedRepositoryId>abc-1000</stagedRepositoryId> <description>some description here</description> </data> </promoteResponse>
After this, it's easy, just make PUT requests to /service/local/staging/deployByRepositoryId/<repo-id>
. So for example:
curl -v -u admin:admin123 -H "Content-type: application/x-rpm" --upload-file some.rpm http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/abc-1000/com/mycompany/artifact/1.0/artifact-1.0.rpm
Finally, you can close the staging repository with a POST request to ""/service/local/staging/profiles/<profile-id>/finish". The payload for this request is:
<promoteRequest> <data> <stagedRepositoryId>abc-1000</stagedRepositoryId> <description>some description here</description> </data> </promoteRequest>