Nexus 3 - File Upload to hosted Maven Repository

Christoph Forster picture Christoph Forster · Jan 31, 2017 · Viewed 14.1k times · Source

I want to upload some files to a newly generated hosted Maven Repository on my Nexus OSS 3 Instance.

I need to use curl (not maven or something else) for the upload.

I tried the following statement (Port is not necessary - I have a NginX as reverse Proxy)

curl -v -F r=releases -F hasPom=false -F e=jar -F g=com.my.group -F a=myArtifact -F v=1.0.0-RC1 -F p=jar --upload-file "myArtifact.jar" -u user:password123 http://myNexusInstance.com/repository/myRepository

This Command produces the following Error:

* Server auth using Basic with user 'user'
PUT /repository/myRepository HTTP/1.1
Host: myNexusInstance.com
Authorization: Basic xxxx=
User-Agent: curl/7.49.1
Accept: */*
Transfer-Encoding: chunked
Expect: 100-continue
HTTP/1.1 100 Continue
} [16380 bytes data]
HTTP/1.1 400 Invalid path for a Maven 2 repository

I tried googling around but did not find any Solution (Neither in the Nexus OSS 3.x Documentation nor in different Forums)

The Nexus Repository is setup with the following configuration values:

  • Format: maven2
  • Type: hosted
  • Version policy: Release
  • Layout policy: Strict
  • Deployment policy: Allow redeploy (also tested "Disable redeploy")

What is wrong here?

Answer

DarthHater picture DarthHater · Jan 31, 2017

You can't use the service urls in Nexus Repository 3. To do something like you are trying to do, try this:

curl -v -u admin:admin123 --upload-file myArtifact.jar http://nexusURL:nexusPORT/repository/myRepository/com/my/group/myArtifact/1.0.0-RC1/myArtifact-1.0.0-RC1.jar

That SHOULD do the trick?

For some good reading, you can check out the following link that explains a remote repository layout (and hopefully helps explain why what I suggested to do works):

https://cwiki.apache.org/confluence/display/MAVEN/Remote+repository+layout#Remoterepositorylayout-Repositoryartifactlayout