100

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.

4
  • 1
    In my answer here I explained both approaches - for http and https.
    – grajsek
    Oct 19, 2016 at 12:06
  • 17
    why on earth would they leave out this essential piece of functionality? Dec 14, 2016 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 with detailed documentation. The released version at the time of this answer supports GAV style and raw uploads as well. May 31, 2017 at 13:58
  • Official documentation at this time : help.sonatype.com/repomanager3/using-nexus-repository/… Dec 7, 2022 at 10:32

8 Answers 8

90

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

8
  • 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 {}->127.0.0.1:8081: Broken pipe and so on... Nov 29, 2016 at 8: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, 2016 at 20:47
  • 1
    @ErayTuncer In my example i have validated using nexus 3. Could you past full stack trace?
    – bpedroso
    Dec 1, 2016 at 12:16
  • 7
    To get rid of the NoSuchElementException: remove the quotes from the -Durl switch's value. Took me 2 hours of search.
    – sanya
    Mar 30, 2017 at 14:51
  • 2
    do not forget to wrap this "servers" snippet into "<settings></settings>" element if you are creating a new settings.xml file. otherwise this section will be silently ignored.
    – Alex
    Aug 3, 2017 at 3: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.

1
  • 29
    As time goes by this is turning out to be a MASSIVE PITA.
    – demaniak
    May 24, 2017 at 14:41
32

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

5
  • We had 3.7 installed and the feature matrix was saying this should exist (3.10 is now current). I was going mad trying to figure out how it was implemented. This answer was very helpful. I'd up vote you 10 times if I could. Apr 18, 2018 at 16:21
  • Bower (hosted) repositories don't have upload feature :/
    – Arkadi
    Apr 24, 2018 at 13:29
  • @tobias what's the typical value for extension? Aug 13, 2020 at 18:46
  • @Varun Verma filename extension e.g. jar
    – 17hao
    Nov 25, 2020 at 3:04
  • And in case you still don't see the "Upload" button: you need to assign the nx-component-upload privilege to the user. (see Sonatype Documentation: Uploading Components). Jan 31, 2023 at 14:59
30

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/'
3
  • 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. May 31, 2016 at 18:35
  • 1
    @PawełGłowacz the Jira issue for the upload functionality in 3.x is here: issues.sonatype.org/browse/NEXUS-10121
    – mvreijn
    Mar 1, 2017 at 16:13
  • 1
    Read curl's man file about the --fail switch - its not fail-safe
    – caduceus
    Jun 12, 2020 at 12:34
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

2
  • 2
    But only for Windows users?
    – TOUDIdel
    Jan 6, 2018 at 19:35
  • 2
    At this moment, yes
    – Ron Badur
    Jan 6, 2018 at 20:00
2

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/
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]
1

My team use Gradle and Nexus OSS 3.5.2,

I have found a solution: upload artyfacts from localhost (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

Not the answer you're looking for? Browse other questions tagged or ask your own question.