Sonatype - Nexus Latest
Sonatype - Nexus Latest
• 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.
Installation
https://www.sonatype.com/download-oss-sonatype
Windows
Extract the zip file. Once you extract the zip file you will see the 2 directories.
---------------------------------------------------------------------------------------------------------------------
Mac
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
#cd NEXUS_HOME/bin
#./nexus start (OR) ./nexus run (OR) ./nexus \run ----> Mac/Linux
(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
Nexus Repository 2.14.5 is now available with support for upgrading to Nexus Repository
Manager 3.5.0 or higher.
--------------------------------------------------------------------------------------------------------------------
Nexus Directory structure
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.
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
• 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
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.
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.
--------------------------------------------------------------------------------------------------------------------
Maven Integration with Nexus
<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>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>******</password>
</server>
</servers>
Now run the below command to upload the artifact into nexus using below command.
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.
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.
<version>0.0.1-SNAPSHOT</version>
--------------------------------------------------------------------------------------------------------------------
What is SnapShot and what is Release?
--------------------------------------------------------------------------------------------------------------------
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.
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.
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>
Create Users
--------------------------------------------------------------------------------------------------------------------
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-