Search code examples
restpublishnexus

Publish artifact to Nexus via REST API, POST


Not to savvy with Nexus administration....

Open a console to look at the network call when uploading an artifact "by hand". Want to skip using Maven or Ivy to upload to Nexus. Everything query wise goes through ExtJS XHR calls except for the posting of artifact information which shows up in Chrome Developer Tools as a Documents call (assuming this is a form submit issued via ExtJS).

Haven't tried simulating with curl (no idea how multipart forms are handled in curl if possible) but is this the only way to "post" artifacts besides doing a traditional publish from Ivy or Maven? Looks like Nexus has a Java API but would like to remain in the REST HTTP world (hoping for Nexus REST service that basically does the multipart form post with something like apache's HTTPCLIENT).


Solution

  • Use curl:

    curl -v \
        -F "r=releases" \
        -F "g=com.acme.widgets" \
        -F "a=widget" \
        -F "v=0.1-1" \
        -F "p=tar.gz" \
        -F "file=@./widget-0.1-1.tar.gz" \
        -u myuser:mypassword \
        http://localhost:8081/nexus/service/local/artifact/maven/content
    

    This will work with non-java dependencies for people not using maven. See my comments on this answer: https://stackoverflow.com/a/19699327/231573.