How to upload the artifacts in Sonatype Nexus | Tutorial

 artifacts-in-sonatype-nexus
1. Upload Artifacts using NEXUS GUI
https://books.sonatype.com/nexus-book/reference/using-sect-uploading.html
2. Upload Artifacts using Maven pom.xml using “mvn deploy”
Update your pom.xml with following…
<distributionManagement>
  <repository>
  <id>deployment</id>
  <name>Internal Releases</name>
  <url>http://uvo1ppw4qmimuo3p1tg.vm.cld.sr:8081/nexus/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://uvo1ppw4qmimuo3p1tg.vm.cld.sr:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Update your setting.xml with following
<servers>
<server>
<id>deployment</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
3. Upload Artifacts using Linux Commands
> curl -v -u admin:admin123 –upload-file pom.xml http://localhost:8081/nexus/content/repositories/releases/org/foo/1.0/foo-1.0.pom
> 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
4. Upload Artifacts using mvn commands
Upload Artifacts using Maven “deploy-file” Deployment
Example without a pom file:
mvn deploy:deploy-file -DgroupId=com.somecompany -DartifactId=project -Dversion=1.0.0 -DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -Durl=http://localhost:8081/nexus/content/repositories/releases -Dfile=target/project-1.0.0.jar
With a pom file:
mvn deploy:deploy-file -DgroupId=com.somecompany -DartifactId=project -Dversion=1.0.0 -DgeneratePom=false -Dpackaging=jar -DrepositoryId=nexus -Durl=http://localhost:8081/nexus/content/repositories/releases -DpomFile=pom.xml -Dfile=target/project-1.0.0.jar
With a Zip file:
> mvn deploy:deploy-file -DgroupId=com.fanniemae.securitiesprocessor -DartifactId=sp_adapter_mbs -Dversion=0.0.1-SNAPSHOT -Dpackaging=zip -Dfile=sp_adapter.zip -DrepositoryId=deployment -Durl=http://nexus-server:8081/nexus/content/repositories/snapshots/
Note: You need to update your setting.xml with following. where as The “repositoryId” parameter is not a Nexus repository ID, it is the ID of a server section in your settings.xml file which has then credentials needed for deployment.
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
Tagged : / / / / / /