0% found this document useful (0 votes)
310 views

Sonatype - Nexus Latest

Uploaded by

Sachin Kuchhal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
310 views

Sonatype - Nexus Latest

Uploaded by

Sachin Kuchhal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Mithun Technologies Nexus Author Mithun Reddy L

+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Sonatype Nexus OSS (Open Source Software)

• Introduction
• Installation
o Password and Email change for admin User
o Email server Configuration
o Port Number Change
o Context root change
• Nexus Directory structure
• Create the Repositories (mave2(hosted) and maven2(proxy))
• Integrate the Maven with Nexus
• Create Users

Introduction

Nexus is a Artifactory repository manager allows to store and retrieve build artifacts.

Nexus Repository Manager is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus"
are trademarks of Sonatype, Inc.

Before Stating installation need to verify the below software should install.

Java: Verify with java -version command.


Maven: Verify with mvn -version.

Installation

Nexus Repository Manager can be downloaded from below url.

https://www.sonatype.com/download-oss-sonatype

Windows

Download the Windows version of Nexus repository.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Copy downloaded software (nexus-3.8.0-02-win64.zip) into one directory


(C:\DevOps_Softwares\Nexus) .

Extract the zip file. Once you extract the zip file you will see the 2 directories.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Start the Nexus Server


-----------------------------

Open the command prompt as Administrator and go to the directory


(C:\DevOps_Softwares\Nexus\nexus-3.9.0-01\bin) where you have copied nexus
software(nexus-3.8.0-02-win64.zip).

Start the Nexus repository server as follows.


Execute the below command.
nexus.exe /run

Once it started successfully, you will see below output.

---------------------------------------------------------------------------------------------------------------------

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Mac

Download the Mac version of Nexus repository.

Copy downloaded software (nexus-3.7.1-02-mac.tgz) into one directory and extract it.

Go to the directory where you have copied nexus software(nexus-3.7.1-02-mac.tgz) and extract it
using the below commands.

#gunzip nexus-3.7.1-02-mac.tgz

#tar xvf nexus-3.7.1-02-mac.tar

Start the Nexus repository server as follows.

#cd NEXUS_HOME/bin

#./nexus start (OR) ./nexus run (OR) ./nexus \run ----> Mac/Linux

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

(OR)

(OR)

---------------------------------------------------------------------------------------------------------------------
Nexus Repository Manager is a Java application that requires a Java Runtime Environment.
When you start the repository manager, It runs within a servlet container called Eclipse Jetty, and
it is started with a native service wrapper called the Tanuki Java Service Wrapper.

Once the nexus repository manager has been started, its web interface can be accessed under this
URL:
http://localhost:8081/ ---> 3.x Releases
http://localhost:8081/nexus ---> 2.x Releases

The default credentials are admin/admin123.

Nexus Repository 2.14.5 is now available with support for upgrading to Nexus Repository
Manager 3.5.0 or higher.

Once you installed successfully, do the below changes.


a) Change the Administrative Email and Password as follows.
Click on username (admin , on right side top corner) and update the email as follows.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Then click on Save button.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

b) Configure the SMTP Settings

--------------------------------------------------------------------------------------------------------------------
Nexus Directory structure

The installation directory having below directories:


bin
deploy
etc
lib
public
system

bin: contains the nexus startup script itself as well as startup-related configuration files.
etc: contains configuration files.
lib: contains binary libraries related to Apache Karaf.
public: contains public resources of the application.
system: contains all components and plugins that constitute the application.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Data Directory
The data directory, found by default at ../sonatype-work/nexus3, includes subdirectories that
contain all the components, repositories, configurations and other data presented by the
repository manager. The subdirectories are listed as:
blobs/
This is the default location of the blob store. If you provided a fully qualified path when
creating a new blob store, it may not end up in this directory.
cache/
This directory contains information on currently cached Karaf bundles
db/
This directory contains the OrientDB databases which are the primary storage for your
repository manager’s metadata
elasticsearch/
This directory contains the currently configured state of Elasticsearch
etc/
This directory contains the main runtime configuration and customization of the repository
manager. The files are explained further in Configuring the Runtime Environment.
health-check/
This directory contains cached reports from the Repository Health Check feature
keystores/
This contains the automatically generated key used to identify your repository manager
log/
This directory contains several log files that capture information about various aspects of the
running repository manager. The nexus.log and request.log files are rotated every day so this
directory also contains archived copies of these files. To reclaim disk space, you can delete
old log files from the logs directory. Log files found in this directory include:

• nexus.log - The main repository manager application log. Log messages contain standard log
output fields including date/time, log level, the associated thread, class and message.
• request.log - Used to log http access requests to a running repository manager. Log messages
contain information such as client host, user and HTTP request attributes including status code,
bytes, and user-agent header.
• jvm.log - Contains JVM stdout, stderr and thread dump messages

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

• karaf.log - This is the Apache Karaf container log file which contains messages specific to the
repository manager startup

The log directory also contains a tasks subdirectory which contains separate, uniquely
named (by date, time and task name) log output files for each task that is run. See Task
Logging for more details concerning naming strategy and content of these files.
tmp/
This directory is used for temporary storage

--------------------------------------------------------------------------------------------------------------------
How to stop the Nexus Server?
Ans) Go to the NEXUS_INSTALLATION_HOME Directory and execute the below command.
#./nexus stop

(OR)
The nexus server is started with run command like
./nexus run ---> Mac/Linux
nexus.exe /run ---> Windows

We will use Ctrl + c to stop the server.


--------------------------------------------------------------------------------------------------------------------
How to change the port number?

To change the default HTTP port from 8081 to custom port, follow the below steps.
Go to the etc directory and open the nexus-default.properties file and update the port number
from 8081 to your custom port.

application-port=8081 ---> By default port number.


application-port=9090 ---> Customised port number.
--------------------------------------------------------------------------------------------------------------------
How to change the context root?
Go to the etc directory and open the nexus-default.properties file and update the context root as
follows.

nexus-context-path=/ ---> By default context root


nexus-context-path=/mithuntechnologies ---> Customised context root
--------------------------------------------------------------------------------------------------------------------
Nexus provides for three different kinds of repositories: Proxy Repositories, Hosted repositories,
and Virtual repositories.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Create the repositories

Login into Nexus repo with admin credentials and click on Administration Button and
expand the Repository and click on Repositories and click on Create repository.

Select the repository type.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

--------------------------------------------------------------------------------------------------------------------
Maven Integration with Nexus

update the pom.xml with below lines for each application.

Note: After </dependencies> tag you can put below lines.

<distributionManagement>
<repository>
<id>nexus</id>
<name>Mithun Technologies Releases Nexus Repository</name>
<url>http://localhost:8081/repository/mithun-technologies-releases</url>
</repository>
<snapshotRepository>
<id>nexus</id>

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

<name>Mithun Technologies Snapshot Nexus Repository </name>


<url>http://localhost:8081/repository/mithun-technologies-snapshots</url>
</snapshotRepository>
</distributionManagement>

Add the below lines in MAVEN_HOME/conf/settings.xml file.

<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>******</password>
</server>
</servers>

Note: Here replace **** with actual password.

Now run the below command to upload the artifact into nexus using below command.

mvn clean deploy


--------------------------------------------------------------------------------------------------------------------
Possible Errors:

1) Error

Solution:

Login into Nexus server, go to that repository, in Hosted option select the Deployment policy as
“Allow redeploy” option and click on Save button as follows.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

2) Error

Solution:

Open the settings.xml file and go to the servers section and verify the Nexus credentials.

<server>
<id>nexus</id>
<username>admin</username>
<password>********</password>
</server>

3) Error

Solution :
Login into Nexus repo and select that particular repo (maven-releases) and check the
Maven2 option Version policy.

Change from Snapshot to Release.

Suppose if you put version as SNAPSHOT

<version>0.0.1-SNAPSHOT</version>
--------------------------------------------------------------------------------------------------------------------
What is SnapShot and what is Release?

--------------------------------------------------------------------------------------------------------------------

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Using below Maven Central Repo we can download libraries.


https://search.maven.org/

How to deploy(store) external artifacts into nexus using command?


mvn deploy:deploy-file -DgroupId=junit -DartifactId=junit -Dversion=3.8.1 -
DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -
Durl=http://localhost:8086/mithuntechnologies/repository/remoterepo-mithun-technologies -
Dfile=/Users/bhaskarreddyl/Desktop/junit-3.8.1.jar
--------------------------------------------------------------------------------------------------------------------
How to use the remote repository instead of default Maven central repository?
Ans) Add below code snippet in pom.xml before <deployments> element.
<repositories>
<repository>
<id>nexus</id>
<url>http://localhost:8086/mithuntechnologies/repository/remote-repo-mithun-
technologies/</url>
</repository>
</repositories>

To Restrict, to get it from only remote repo instead from Maven Central Repo, add below code
snippet in
settings.xml

<mirror>
<id>nexus</id>
<name>Remote Repository</name>
<url>http://localhost:8085/mithuntechnologies/repository/remote-repo-mithun-technologies/</url>
<mirrorOf>*</mirrorOf>
</mirror>
--------------------------------------------------------------------------------------------------------------------
Proxy to Maven Central repo
A repository that proxies everything you download from Maven Central. Next time you
download the same dependency; it will be cached in your Nexus.
Create a new maven (proxy) repository and configure it like:
We’ll create a new Maven proxy in the Nexus Repository Manager UI.

Open the Nexus Repository Manager user interface.

Click Administration in the top navigation menu, and then select Repositories.
Click Create repository, and then choose the maven2 (proxy) recipe from the list.
Add the following text in the required fields:
Name: mithuntechnologies-proxy-repo
Remote storage URL: https://repo1.maven.org/maven2
Click Create repository to complete the form.

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Settings.xml

<mirror>
<id>nexus</id>
<name>Remote Proxy Repository</name>
<url>http://localhost:8085/mithuntechnologies/repository/mithuntechnologies-proxy-repo/</url>
<mirrorOf>*</mirrorOf>
</mirror>

If you want only to download dependencies from Nexus, put this in the pom.xml:

<repositories>
<repository>
<id>nexus</id>
<url>http://localhost:8085/mithuntechnologies/repository/mithuntechnologies-proxy-
repo/</url>
</repository>
</repositories>

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

Create Users

Administration ---> Security ---> Users ---> Create local user

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

--------------------------------------------------------------------------------------------------------------------

© 2019 all rights Reserved by Mithun Technologies [email protected]


Mithun Technologies Nexus Author Mithun Reddy L
+91-9980923226 [email protected] Web site http://mithuntechnologies.com

References
https://help.sonatype.com/display/NXRM3/Installation
https://help.sonatype.com/display/NXRM3/Run+as+a+Service
https://help.sonatype.com/display/NXRM3/Maven+Repositories
https://support.sonatype.com/hc/en-us/articles/213465348-How-do-I-configure-my-Gradle-build-
to-publish-artifacts-to-Nexus-

© 2019 all rights Reserved by Mithun Technologies [email protected]

You might also like