Installation of Sonatype Nexus
# mkdir -p /opt/nexus
# cd /opt/nexus/
# wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
or Go to below link
https://www.sonatype.com/download-oss-sonatype
download the required nexus bundle and save it to your computer
Use Winscp to transfer file from your PC to Linux machine.
untar the file.
# tar zxvf nexus-2.14.9-01-bundle.tar.gz
[ec2-user@ip-172-31-26-6 ~]$ ls -ltr
total 79816
drwxr-xr-x 8 ec2-user ec2-user 113 Jun 27 2018 nexus-2.14.9-01
drwxr-xr-x 3 ec2-user ec2-user 37 Jun 27 2018 sonatype-work
-rw-rw-r-- 1 ec2-user ec2-user 81729327 Jul 19 2018 nexus-2.14.9-01-bundle.tar.gz
Create a softlink
[ec2-user@ip-172-31-26-6 ~]$ ln -s nexus-2.14.9-01 nexus
[ec2-user@ip-172-31-26-6 ~]$ cd nexus
[ec2-user@ip-172-31-26-6 nexus]$ ls -ltr
total 20
drwxr-xr-x 2 ec2-user ec2-user 6 Jun 27 2018 tmp
drwxr-xr-x 2 ec2-user ec2-user 6 Jun 27 2018 logs
-rw-r--r-- 1 ec2-user ec2-user 782 Jun 27 2018 NOTICE.txt
-rw-r--r-- 1 ec2-user ec2-user 11006 Jun 27 2018 LICENSE.txt
drwxr-xr-x 2 ec2-user ec2-user 4096 Apr 23 12:14 lib
drwxr-xr-x 4 ec2-user ec2-user 111 Apr 23 12:14 nexus
drwxr-xr-x 2 ec2-user ec2-user 204 Apr 23 12:14 conf
drwxr-xr-x 3 ec2-user ec2-user 47 Apr 23 12:14 bin
# go to bin directory and start the nexus server.
[ec2-user@ip-172-31-26-6 nexus]$ cd bin/
[ec2-user@ip-172-31-26-6 bin]$ ls
jsw nexus nexus.bat
[ec2-user@ip-172-31-26-6 bin]$ ./nexus start
Starting Nexus OSS...
Started Nexus OSS.
Access the nexus URL
Check the logs
[ec2-user@ip-172-31-8-85 bin]$ cd ../logs/
[ec2-user@ip-172-31-8-85 logs]$
[ec2-user@ip-172-31-8-85 logs]$ tail wrapper.log
jvm 1 | 2019-05-03 04:28:40,162+0000 INFO [jetty-main-1] org.sonatype.nexus.proxy.registry.DefaultRepositoryTypeRegistry - Registered default repository types.
jvm 1 | 2019-05-03 04:28:40,371+0000 INFO [jetty-main-1] org.sonatype.nexus.events.EventSubscriberHost - Initialized
jvm 1 | 2019-05-03 04:28:40,378+0000 INFO [jetty-main-1] org.sonatype.nexus.NxApplication -
jvm 1 | -------------------------------------------------
jvm 1 |
jvm 1 | Initializing Nexus Repository Manager OSS 2.14.9-01
jvm 1 |
jvm 1 | -------------------------------------------------
jvm 1 | 2019-05-03 04:28:40,378+0000 INFO [jetty-main-1] org.sonatype.nexus.NxApplication - Activating locally installed plugins...
jvm 1 | 2019-05-03 04:28:43,104+0000 INFO [jetty-main-1] com.sun.jersey.server.impl.application.WebApplicationImpl - Initiating Jersey application, version 'Jersey: 1.17.1 02/28/2013 12:47 PM'
http://ec2-52-66-203-237.ap-south-1.compute.amazonaws.com:8081/nexus/
Create two repository
spring-snapshots
spring-releases
clone the git URL and edit the pom.xml
git clone https://github.com/rkidambi11/Maven.git --- this should be in /var/lib/jenkins/ of Maven server.
[root@ip-172-31-28-96 springexample]# cat pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>SpringExample</artifactId>
<packaging>jar</packaging>
<version>2.0.2-SNAPSHOT</version>
<name>SpringExample</name>
<!--url>http://maven.apache.org</url-->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>spring-deploy</id>
<distributionManagement>
<repository>
<id>spring-releases</id>
<name>spring-releases</name>
<url>http://ec2-52-66-203-237.ap-south-1.compute.amazonaws.com:8081/nexus/content/repositories/spring-releases/</url>
</repository>
<snapshotRepository>
<id>spring-snapshots</id>
<name>spring-snapshots</name>
<url>http://ec2-52-66-203-237.ap-south-1.compute.amazonaws.com:8081/nexus/content/repositories/spring-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
</project>Do mvn clean
mvn clean validate
mvn clean install
mvn clean deploy ### you have to create user, privilege, repository in nexus and Role.
after that go to .m2 directory and touch a settings.xml with below details
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<servers>
<server>
<id>spring-snapshots</id>
<username>my_login</username>
<password>my_password</password>
</server>
<server>
<id>spring-releases</id>
<username>my_login</username>
<password>my_password</password>
</server>
</servers>
...
</settings>
Run the below commmands to send data from maven to nexus repository.
mvn -Pspring-deploy deploy