How to manually deploy artifacts in Nexus Repository Manager OSS 3
Asked Answered
B

8

101

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.

Bevbevan answered 31/5, 2016 at 10:25 Comment(4)
In my answer here I explained both approaches - for http and https.Regrate
why on earth would they leave out this essential piece of functionality?Ozellaozen
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.Stimson
Official documentation at this time : help.sonatype.com/repomanager3/using-nexus-repository/…Sixpenny
I
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

Intine answered 8/3, 2018 at 12:11 Comment(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.Al
Bower (hosted) repositories don't have upload feature :/Borderline
@tobias what's the typical value for extension?Virtuosic
@Varun Verma filename extension e.g. jarCollective
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).Siloum
N
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

Neolith answered 28/9, 2016 at 20:31 Comment(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...Inarch
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.Neolith
I think the problem is that I am using Nexus 3, not Nexus 2.Inarch
@ErayTuncer In my example i have validated using nexus 3. Could you past full stack trace?Neolith
Using Maven 3.3.9, I'm getting the following error: Cannot access 'http://XXX/repository/XXX' with type default using the available connector factories: BasicRepositoryConnectorFactory: Can not access 'http://XXX/repository/XXX' using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementExceptionMlawsky
To get rid of the NoSuchElementException: remove the quotes from the -Durl switch's value. Took me 2 hours of search.Mlawsky
@Neolith how I upload 3rd pom's without jars?Threlkeld
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.Utricle
A
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.

Autorotation answered 6/6, 2016 at 18:39 Comment(1)
As time goes by this is turning out to be a MASSIVE PITA.Rationalism
I
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

Intine answered 8/3, 2018 at 12:11 Comment(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.Al
Bower (hosted) repositories don't have upload feature :/Borderline
@tobias what's the typical value for extension?Virtuosic
@Varun Verma filename extension e.g. jarCollective
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).Siloum
C
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/'
Cacao answered 31/5, 2016 at 13:30 Comment(3)
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.Deadlight
@PawełGłowacz the Jira issue for the upload functionality in 3.x is here: issues.sonatype.org/browse/NEXUS-10121Dukes
Read curl's man file about the --fail switch - its not fail-safeSignatory
T
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

Threlkeld answered 6/7, 2017 at 17:56 Comment(2)
But only for Windows users?Nelidanelie
At this moment, yesThrelkeld
S
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/
Shaquana answered 29/6, 2020 at 11:42 Comment(0)
P
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

Peevish answered 28/1, 2018 at 11:45 Comment(0)
N
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]
Neom answered 7/1, 2019 at 8:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.