79

After installing Nexus Repository Manager OSS 3 I do not see option Artifact Upload to upload artifacts through web page.

In Nexus Repository Manager OSS 2.13 there is option to do that operation.

Anyone can show me the way how to upload artifacts to hosted repository in Nexus 3?

EDIT: From 3.9.0 version, this functionality is implemented.

Paweł Głowacz
  • 2,636
  • 3
  • 15
  • 24
  • 1
    In my answer [here](http://stackoverflow.com/a/40130685/2614103) I explained both approaches - for http and https. – grajsek Oct 19 '16 at 12:06
  • 17
    why on earth would they leave out this essential piece of functionality? – Kees de Kooter Dec 14 '16 at 21:33
  • 8
    Since the upload GUI still not part of Nexus 3, we have created a lightweight solution to provide the missing interface. You can host a html page in a raw repository of your Nexus3 instance, and when you access that page from the browser, it will provide an upload GUI similar to the one in Nexus2. The project can be found on [GitHub](https://github.com/TOPdesk/nexus3-artifact-upload) with detailed documentation. The released version at the time of this answer supports GAV style and raw uploads as well. – István Rábel May 31 '17 at 13:58

8 Answers8

72

I'm using maven deploy file.

mvn deploy:deploy-file -DgroupId=my.group.id \
    -DartifactId=my-artifact-id \
    -Dversion=1.0.0.1 \
    -Dpackaging=jar \
    -Dfile=foo.jar \
    -DgeneratePom=true \
    -DrepositoryId=my-repo \
    -Durl=http://my-nexus-server.com:8081/repository/maven-releases/

UPDATE: As stated in comments using quotes in url cause NoSuchElementException

But I have add server config in my maven (~/.m2/settings.xml).

<servers>
  <server>
    <id>my-repo</id>
    <username>admin</username>
    <password>admin123</password>
  </server>
</servers>

References:

Maven Apache - Guide 3rd party jars

Ilya
  • 1,932
  • 11
  • 18
bpedroso
  • 3,328
  • 3
  • 24
  • 32
  • Do I have to enable or install anything to deploy like that? I get following errors when I try : Nov 29, 2016 11:27:31 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://127.0.0.1:8081: Broken pipe and so on... – Eray Tuncer Nov 29 '16 at 08:31
  • No. ONly pure maven. Do you have proxy? Maybe you need to ignore localhost / 127.0.0.1 there / or this ip and port are correct? I'llnsearch other sugestion to solve this eception. – bpedroso Nov 30 '16 at 20:47
  • I think the problem is that I am using Nexus 3, not Nexus 2. – Eray Tuncer Dec 01 '16 at 06:59
  • 1
    @ErayTuncer In my example i have validated using nexus 3. Could you past full stack trace? – bpedroso Dec 01 '16 at 12:16
  • Using Maven 3.3.9, I'm getting the following error: Cannot access '[http://XXX/repository/XXX](http://XXX/repository/XXX/)' with type default using the available connector factories: BasicRepositoryConnectorFactory: Can not access '[http://XXX/repository/XXX](http://XXX/repository/XXX/)' using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException – SandorRacz Mar 30 '17 at 14:25
  • 7
    To get rid of the NoSuchElementException: remove the quotes from the -Durl switch's value. Took me 2 hours of search. – SandorRacz Mar 30 '17 at 14:51
  • @bpedroso how I upload 3rd pom's without jars? – Ron Badur May 09 '17 at 16:50
  • 1
    do not forget to wrap this "servers" snippet into "" element if you are creating a new settings.xml file. otherwise this section will be silently ignored. – Alex Aug 03 '17 at 03:01
43

This isn't currently implemented in the UI in Nexus 3 (see https://issues.sonatype.org/browse/NEXUS-10121). You'll need to use curl or mvn deploy or some other option.

heckj
  • 6,120
  • 2
  • 31
  • 45
Keith Starling
  • 431
  • 4
  • 3
28

You can upload artifacts via their native publishing capabilities (e.g. maven deploy, npm publish).

You can also upload artifacts to "raw" repositories via a simple curl request, e.g.

curl --fail -u admin:admin123 --upload-file foo.jar 'http://my-nexus-server.com:8081/repository/my-raw-repo/'
RCross
  • 4,399
  • 3
  • 35
  • 39
  • 2
    Yes i can do this by `mvn deploy` and it works perfectly but i did not realize that they removed `Artifact Upload` option from latest `Nexus`. – Paweł Głowacz May 31 '16 at 18:35
  • 1
    @PawełGłowacz the Jira issue for the upload functionality in 3.x is here: https://issues.sonatype.org/browse/NEXUS-10121 – mvreijn Mar 01 '17 at 16:13
  • 1
    Read curl's man file about the --fail switch - its not fail-safe – caduceus Jun 12 '20 at 12:34
26

This is implemented in Nexus since Version 3.9.0.

  • Login
  • Select Upload

enter image description here

  • Fill out form and upload Artifact

enter image description here

Tobias Rath
  • 319
  • 3
  • 6
3

My Team built a command line tool for uploading artifacts to nexus 3.x repository, Maybe it's will be helpful for you - Maven Artifacts Uploader

Ron Badur
  • 1,543
  • 2
  • 10
  • 25
1

My team use Gradle and Nexus OSS 3.5.2,

I have found a solution: upload artyfacts from locakhost (I checked Nexus documentation and did not found anything about uploading artifacts from folders) => I have shared directory (use Apache httpd) and connected one to created new Nexus proxy repository. Now when I want to add my own artifacts I can upload ones into shared directory in my remote server.

Maybe someone find my solution useful: enter image description here

My question is here: Is it possible to deploy artifacts from local folder in Sonatype Nexus Repository Manager 3.x

kozmo
  • 2,246
  • 1
  • 19
  • 35
1

For Windows:

mvn deploy:deploy-file -DgroupId=joda-time -DartifactId=joda-time -Dversion=2.7 -Dpackaging=jar -Dfile=joda-time-2.7.jar 
-DgeneratePom=true -DrepositoryId=[Your ID] -Durl=[YourURL]
Chinmoy
  • 1,028
  • 10
  • 12
0

To use mvn deploy:deploy-file, must add ~./m2/settings.xml

<settings>
  <servers>
    <server>
      <id>nexus-repo</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
</settings>

command:

mvn deploy:deploy-file -DgroupId=com.example \
                                       -DartifactId=my-app \
                                       -Dversion=2.0.0 \
                                       -Dpackaging=jar \
                                       -Dfile=my-app.jar \
                                       -DgeneratePom=true \
                                       -DrepositoryId=nexus-repo \
                                       -Durl=http://localhost:8081/repository/maven-releases/
GolamMazid Sajib
  • 6,630
  • 4
  • 17
  • 32