Uploading to a Staging Repository via REST API

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>
Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Nicolas Rouquette

    Could you please update the nexus-staging-plugin REST API doc to include /staging/deployByRepositoryId ?

  • 0
    Avatar
    Stefan Leitich
    Mind that if you try a request with an empty file, Nexus will respond with 400.
  • 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