3

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).

Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
  • 1
    Be warned. Publishing snapshot revisions requires the client to update the revised Maven module's metadata file... Appears to be an undocumented "feature" :-) – Mark O'Connor Jun 14 '12 at 21:22

2 Answers2

18

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.

Community
  • 1
  • 1
Ed I
  • 7,008
  • 3
  • 41
  • 50
  • This will *not* expand the archive on the server side, meaning that you will not be able to download only some of the files that are deployed to the nexus server. In many cases that's exactly what non-java people would desire. – sorin Jun 29 '15 at 17:02
  • 2
    I get "405 Method Not Allowed" as response status. It says "HTTP method POST is not supported by this URL". Do I have to install or enable something to benefit from the Rest API. – Eray Tuncer Nov 29 '16 at 07:42
  • 1
    Ok I think it is because Nexus 3 does not support what you have mentioned here. – Eray Tuncer Nov 29 '16 at 11:40
0

Found this response from Sonatype:

In a nutshell, it's possible to POST the artifact directly, but what about the other files required for your Maven module? The most important being a POM...

The simplest way to upload a file is to use the deploy-file plugin:

Upload artifacts to Nexus, without Maven

Is there a compelling reasons for not using the Maven client?

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • The Maven POM can be attached in the multipart form upload. Will write back with an example in Curl. Not using Maven for all sorts of reasons but the majority of repositories are maven based thus us trying out Nexus. Ivy integrates with Maven repos for example. Just wanted a solution without Maven/Ivy and hopefully via REST. – Matthew Campbell Jun 15 '12 at 07:54