SlideShare a Scribd company logo
Sona type Nexus
• Understanding a Package and package management
• Repository Manager Concepts
• What is Sonatype Nexus
• Installing Sonatype Nexus
• Introduction of User Interface Sonatype Nexus
• Configuration of Sonatype Nexus
• Users and Roles of Sonatype Nexus
• Creating Maven Hosted/Proxy/Group type repository
• How to upload/download an artifacts using Maven from Sonatype Nexus
• How to download a artifacts using Maven from Sonatype Nexus
• Setting up Docker repository using Sonatype Nexus
• Docker Image push/pull using Sonatype Nexus repository
• Setting up npm repository using Sonatype Nexus
• npm using Sonatype Nexus repository
• Yum Repositories using Sonatype Nexus
• Ruby, RubyGems and Gem Repositories using Sonatype Nexus
• Sonatype Nexus Upgrading
• Sonatype Nexus Backup and Restore
• Sonatype Nexus Cleanup Policies
• Sonatype Nexus REST and Integration API
• Sonatype Nexus Webhooks
• Sonatype Nexus .NET Package Repositories with NuGet
Sona type Nexus
Packaging Concepts
Packaging concepts
Packages
Packages are archives of files containing a computer program or a piece of software (such as an
application, shared libraries, development code...) and, eventually, instructions on the way to make
them work.
Package metadata :
A package also contains further information, commonly referred to as Metadata, it include package
description, package version, license details etc.
Package dependencies:
Pre-requisites and other related packages that need to be installed beforehand.
Package concepts
Package formats
Package formats are the type of distributions of softwares or archived files. e.g. rpm, deb, tgz…
Package Manager:
A package manager deals with packages, distributions of software and data in archive files.
Package repositories:
Package repositories are storage location from which software packages may be retrieved and installed
on a computer.
Package Management System
Installing Sona type
Nexus
Repository Management
Concepts
Repository Management Concepts
Repository:
A repository is a storage location where components such as packages, libraries, binaries, or
containers are retrieved so they can be installed or used.
Repository Manager:
A repository manager is a dedicated server application used to manage all the repositories your
development teams use throughout the course of development. For Example
- Central repository for maven (Maven Central)
- NuGet Gallery
- RubyGems.org
Repository Management Concepts
Components
Components:
In Nexus Repository Manager terminology, the term components describe the items such as packages,
libraries, binaries, containers or any other resource produced or used by your software application. In
other different tool chains, components can be called by artifacts, bundles, archives etc.
The typical components are archived files composed of
• Java .jar, .war, .ear file extensions.
• plain .zip or .tar.gz file extensions.
• package formats like nupkg, RPM, and gem.
• executable formats like .exe, .sh files.
Formats
Formats:
A repository format is a communication protocol for storing, retrieving, and indexing components and the
metadata about those components.
The typical formats being supported by Nexus Repository Manager 3 are
• Brower
• Docker
• Maven 2
• npm
• NuGet
• PyPI
• RubyGems
• Yum
Core functions of Repository Manager
• Proxies remote repositories and caches contents.
• Hosts internal repositories.
• Groups repositories into a single repository.
Advantages of Repository Manager
• Manage components.
• Manage software releases with rules and add automated notifications.
• Integration with external security systems like LDAP.
• Control access by authenticating and authorizing specific sets or groups of users.
• View and manage component metadata.
• Host internal customized items not available in remote repositories.
Apache Maven
Introduction
Maven
“Maven is a software management and comprehension tool based on the concept of Project
Object Model (POM) which can manage project build, reporting, and documentation from a central
piece of information”.
POM (Project Object Model):
“As a fundamental unit of work in Maven, POM is an XML file that contains information about
project and configuration details used by Maven to build the project”.
Objectives and Characteristics of Maven
• Maven is more than just Build Tool
• Maven was built considering certain objectives
• Maven Provides:
• Easy Build Process
• Uniform Build System
• Quality Project Information
• Guidelines for Best Practices Development
• Achieved Characteristics:
• Visibility
• Reusability
• Maintainability
Comparison with ANT
1. One level above ANT
2. Higher level of reusability between builds
3. Faster turn around time to set up a powerful build
4. Project website generation
5. Less maintenance
6. Repository management
ANT MAVEN
Target
build.xml
Goal
pom.xml
Main features of Maven
Build-Tool
Dependency Management Tool
Documentation Tool
Project creation in Maven
mvn archetype:generate
-DgroupId = com.mycompany.app
-DartifactId = my-app
-DarchetypeArtifactId = maven-archetype-quickstart
-DinteractiveMode = false
Contents of the created project
 POM
 source tree for your application's sources
 source tree for your test sources
Standard directory layout created project
src/main/java Application/Library sources
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/scripts Application/Library scripts
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
LICENSE.txt Project's license
NOTICE.txt Notices and attributions required by libraries that the project depends on
README.txt Project's readme
Components of POM file
• Metadata: Location of Directories, Developers/Contributors, Dependencies, Repositories
• Dependencies (Transitive Dependencies), Inheritance, and Aggregation
• Key Elements
 Project
 Model Version
 Group ID
 Packaging
 Artifact ID
 Version
 Name
 URL
 Description
Structure of POM file in maven
<project>
<modelVersion> 4.0.0 </modelVersion>
<groupId> com.mycompany.app </groupId>
<artifactId> my-app </artifactId>
<packaging> jar </packaging>
<version> 1.0-SNAPSHOT </version>
<name> Maven Quick Start Archetype </name>
<url> http://maven.apache.org </url>
<dependencies>
<dependency>
<groupId> junit </groupId>
<artifactId> junit </artifactId>
<version> 4.8.2 </version>
<scope> test </scope>
</dependency>
</dependencies>
</project>
Structure of BUILD file in ANT
<project default = "compile">
<property name = "classesdir = " " value = "..."/>
<property name = "libdir" value = "..."/>
<target name = "compile">
<mkdir dir = "${classesdir}"/>
<javac destdir = "${classesdir}">
<src>
<pathelement location = "src/main/java"/>
</src>
<classpath>
<fileset dir = "${libdir}">
<include name = "*.jar"/>
</fileset>
</classpath>
</javac>
</target>
</project>
Nexus User Interface
Installing and Configuring Maven
sudo mkdir maven
cd maven
sudo wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-
bin.tar.gz
sudo tar xavf apache-maven-3.6.0-bin.tar.gz
export PATH=$PATH:/home/vagrant/maven/apache-maven-3.6.0/bin/
mvn --version
Configuring Maven
Nexus Repository Manager Maven Configuration
To use repository manager with Apache Maven, you need to first
configure Maven to check the repository manager instead of the
default, built-in connection to the Central Repository.
To do this, add a mirror configuration and override the default
configuration for the central repository in your settings.xml at
~/maven/apache-maven-3.6.0/conf.
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-proxy-test/</url>
settings.xml
Configuring Maven
Make a maven project
Create a Maven project also known as a Project Object
Model or POM. We’ll use this POM later to cache new
components from Maven Central to your proxy repository.
1. Navigate to your user directory and then create directory
“maven-test”.
2. Open your new directory by changing to maven-test.
3. Create a POM file (pom.xml) with given contents.
pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>nexus-proxy</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
</project>
Introduction to the Nexus tool for DevOps
Maven Repositories
Maven Proxy Repository
Maven Proxy repository
A proxy repository is a repository that is linked to a remote repository, such as the Central Repository to cache to components.
When you search for component for first time, it is retrieved from Central and cached in the repository manager. If you search
for that same component again, it will be found in local storage. This eliminates the need to go to the Central Repository and
reduces bandwidth and time needed to retrieve the components you need.
Create a new Maven proxy in the Nexus Repository Manager UI by following below steps.
1. Open the Nexus Repository Manager user interface.
2. Click Administration in the top navigation menu, and then select Repositories.
3. Click Create repository, and then choose the maven2 (proxy) recipe from the list.
4. Add the following text in the required fields:
• Name: maven-proxy-test
• Remote storage URL: https://repo1.maven.org/maven2
5. Click Create repository to complete the form.
The repository manager is now configured to proxy Maven Central.
Maven Proxy Repository
Cache New Components from Maven Central to the Proxy
1. In your terminal, navigate to the POM file you created, and run the command mvn package. Your build is ready when you
get a “BUILD SUCCESS” message.
2. In Nexus Repository Manager, click Browse in the main toolbar and then select Browse from the left-side menu.
3. Now navigate to maven-proxy-test. You'll see the test components you proxied for the Maven format during the previous
steps.
4. Click on a component name to review its details.
Maven Hosted Repository
Maven Hosted repository
A hosted repository is a repository that act as the authoritative location for your in-house components and store the
components not necessarily available at central repository.
Now add following steps to your settings.xml and pom.xml
settings.xml pom.xml
<project>
...
<distributionManagement>
<repository>
<id>nexus</id>
<name>maven-releases</name>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>maven-snapshots</name>
<url>http://localhost:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>*******</password>
</server>
</servers>
Maven Hosted Repository
Run Snapshot builds
1. In your terminal, navigate to your POM, and run the build with mvn clean deploy. Your build is ready when you see a
“BUILD SUCCESS” message.
2. In Nexus Repository Manager, click Browse in the main toolbar and then select Browse from the left-side menu.
3. Of your repositories, choose maven-snapshots. You'll see the test components from your Maven Snapshots build.
4. Click on a component name to review its details
Maven Hosted Repository
Run Release builds
1. From your POM file, release “SNAPSHOT” from the version tag as shown.
2. Navigate to your POM, and run the build with mvn clean deploy.
Your build is ready when you see a “BUILD SUCCESS” message.
3. In Nexus Repository Manager, click Browse in the main toolbar and then select
Browse from the left-side menu.
4. Now choose maven-releases. You'll see the test components from your Maven
Releases build.
5. Click on a component name to review its details:
Maven Group Repository
Maven Group repository
A proxy repository is a one-stop location where developers can collaborate on a project with all available components assigned
to it. If you’re an administrator you can dynamically add repositories without updating developer settings. If you’re a developer
you can access the contents of the group by sending requests directly to the repository manager.
NOTE: It’s important to note that a group doesn’t store components. You cannot publish or deploy components directly to it.
Groups just aggregate content from other repositories. If you want to modify components in a group repository, publish those
changes to a hosted repository included in the group.
Create a new Maven group in the Nexus Repository Manager UI by following below steps.
1. Select Repositories, then Create repository.
2. Choose the maven2 (group) recipe.
3. Fill out the form, using maven-all as the Name.
4. Drag and drop the Available proxy and hosted repositories you created in the previous lesson to
the Member field
5. Click Save to complete the form.
6. Make a note of the this group URL from the Repositories screen. The repository URL for this example
is: http://localhost:8081/repository/maven-all.
Maven Group Repository
Customize your Settings for Group Access
Customize your seetings.xml for group repository access in the Nexus Repository Manager UI by following below
steps.
1. Copy the group URL from nexus repository and paste the same in settings.xml in into the mirror config
section similar to the sample settings file below:
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-all/</url>
2. Run the maven build for maven-test project using “mvn install”.
3. To locate all grouped components go to the Browse from Administration and select maven-all option.
Setting up npm using
Nexus repository
Setting up ruby gems
using Nexus repository
Introduction to the Nexus tool for DevOps
Setting up yum and .NET
package repositories using
NuGet
Nexus cleanup
policies and REST API
Nexus Upgrading
Introduction to the Nexus tool for DevOps
Nexus Backup and
Restore
Restore from Backup
Follow the below steps to restore data from backup.
1. Stop Nexus Repository Manager
2. Remove the following directories from $data-dir/db
• accesslog
• analytics
• audit
• component
• config
• security
3. Go to the location where you stored the exported databases
4. Copy the corresponding .bak files to $data-dir/restore-from-backup for restoration (Note: For version
3.10.0 or earlier use $data-dir/backup as the restore location)
5. Restart Nexus Repository Manager
6. You can verify the restoration is complete by viewing the fully-restored databases previously removed
from $data-dir/nexus3/db.
Nexus Webhooks
Introduction to the Nexus tool for DevOps
Setup Nexus using
Docker
Thanks

More Related Content

Similar to Introduction to the Nexus tool for DevOps (20)

PDF
A-Z_Maven.pdf
Mithilesh Singh
 
PPT
Mavenppt
Surekha Achanta
 
PPTX
Apache Maven
Rahul Tanwani
 
PPTX
20091112 - Mars Jug - Apache Maven
Arnaud Héritier
 
PPT
Maven
Rajkattamuri
 
PDF
Mavennotes.pdf
AnkurSingh656748
 
PPT
Maven
Sunil Komarapu
 
PPT
Introduction tomaven
Manav Prasad
 
PDF
Build Automation using Maven
Ankit Gubrani
 
PDF
Introduction to Apache Maven
Rajind Ruparathna
 
PPTX
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Martin Bergljung
 
PPTX
An Introduction to Maven
Vadym Lotar
 
PPT
MAVEN
shayan n
 
PPT
Maven in Mule
Anand kalla
 
PDF
Apache maven, a software project management tool
Renato Primavera
 
PDF
Manen Ant SVN
Sriskandarajah Suhothayan
 
PPTX
Introduction to Maven for beginners and DevOps
SISTechnologies
 
PPT
Maven introduction in Mule
Shahid Shaik
 
PDF
Java Builds with Maven and Ant
David Noble
 
A-Z_Maven.pdf
Mithilesh Singh
 
Mavenppt
Surekha Achanta
 
Apache Maven
Rahul Tanwani
 
20091112 - Mars Jug - Apache Maven
Arnaud Héritier
 
Mavennotes.pdf
AnkurSingh656748
 
Introduction tomaven
Manav Prasad
 
Build Automation using Maven
Ankit Gubrani
 
Introduction to Apache Maven
Rajind Ruparathna
 
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Martin Bergljung
 
An Introduction to Maven
Vadym Lotar
 
MAVEN
shayan n
 
Maven in Mule
Anand kalla
 
Apache maven, a software project management tool
Renato Primavera
 
Introduction to Maven for beginners and DevOps
SISTechnologies
 
Maven introduction in Mule
Shahid Shaik
 
Java Builds with Maven and Ant
David Noble
 

More from Puneet Kumar Bhatia (MBA, ITIL V3 Certified) (20)

PPTX
Python Conditional_Statements_and_Functions
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Web programming using python frameworks.
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Azure Fubdamentals (Az-900) presentation.
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Azure - Basic concepts and overview.pptx
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Cloud Computing basics - an overview.pptx
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Microsoft Azure - Basic concepts presentation
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Introduction to Monitoring Tools for DevOps
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Introduction to Monitoring Tools for DevOps
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPT
Introduction to Devops and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Container Orchestration using kubernetes
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PDF
Java Microservices_64 Hours_Day wise plan (002).pdf
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PDF
Java Microservices_64 Hours_Day wise plan (002).pdf
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Changing paradigm in job market
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PDF
Writing first-hudson-plugin
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Python Conditional_Statements_and_Functions
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Web programming using python frameworks.
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Azure Fubdamentals (Az-900) presentation.
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Azure - Basic concepts and overview.pptx
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Cloud Computing basics - an overview.pptx
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Ansible as configuration management tool for devops
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Microsoft Azure - Basic concepts presentation
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Introduction to Monitoring Tools for DevOps
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Introduction to Monitoring Tools for DevOps
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Introduction to Devops and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Container Orchestration using kubernetes
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Java Microservices_64 Hours_Day wise plan (002).pdf
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Java Microservices_64 Hours_Day wise plan (002).pdf
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Changing paradigm in job market
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Ad

Recently uploaded (20)

PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
July Patch Tuesday
Ivanti
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
July Patch Tuesday
Ivanti
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Ad

Introduction to the Nexus tool for DevOps

  • 1. Sona type Nexus • Understanding a Package and package management • Repository Manager Concepts • What is Sonatype Nexus • Installing Sonatype Nexus • Introduction of User Interface Sonatype Nexus • Configuration of Sonatype Nexus • Users and Roles of Sonatype Nexus • Creating Maven Hosted/Proxy/Group type repository • How to upload/download an artifacts using Maven from Sonatype Nexus • How to download a artifacts using Maven from Sonatype Nexus • Setting up Docker repository using Sonatype Nexus • Docker Image push/pull using Sonatype Nexus repository • Setting up npm repository using Sonatype Nexus • npm using Sonatype Nexus repository • Yum Repositories using Sonatype Nexus • Ruby, RubyGems and Gem Repositories using Sonatype Nexus • Sonatype Nexus Upgrading • Sonatype Nexus Backup and Restore • Sonatype Nexus Cleanup Policies • Sonatype Nexus REST and Integration API • Sonatype Nexus Webhooks • Sonatype Nexus .NET Package Repositories with NuGet
  • 4. Packaging concepts Packages Packages are archives of files containing a computer program or a piece of software (such as an application, shared libraries, development code...) and, eventually, instructions on the way to make them work. Package metadata : A package also contains further information, commonly referred to as Metadata, it include package description, package version, license details etc. Package dependencies: Pre-requisites and other related packages that need to be installed beforehand.
  • 5. Package concepts Package formats Package formats are the type of distributions of softwares or archived files. e.g. rpm, deb, tgz… Package Manager: A package manager deals with packages, distributions of software and data in archive files. Package repositories: Package repositories are storage location from which software packages may be retrieved and installed on a computer.
  • 9. Repository Management Concepts Repository: A repository is a storage location where components such as packages, libraries, binaries, or containers are retrieved so they can be installed or used. Repository Manager: A repository manager is a dedicated server application used to manage all the repositories your development teams use throughout the course of development. For Example - Central repository for maven (Maven Central) - NuGet Gallery - RubyGems.org
  • 11. Components Components: In Nexus Repository Manager terminology, the term components describe the items such as packages, libraries, binaries, containers or any other resource produced or used by your software application. In other different tool chains, components can be called by artifacts, bundles, archives etc. The typical components are archived files composed of • Java .jar, .war, .ear file extensions. • plain .zip or .tar.gz file extensions. • package formats like nupkg, RPM, and gem. • executable formats like .exe, .sh files.
  • 12. Formats Formats: A repository format is a communication protocol for storing, retrieving, and indexing components and the metadata about those components. The typical formats being supported by Nexus Repository Manager 3 are • Brower • Docker • Maven 2 • npm • NuGet • PyPI • RubyGems • Yum
  • 13. Core functions of Repository Manager • Proxies remote repositories and caches contents. • Hosts internal repositories. • Groups repositories into a single repository.
  • 14. Advantages of Repository Manager • Manage components. • Manage software releases with rules and add automated notifications. • Integration with external security systems like LDAP. • Control access by authenticating and authorizing specific sets or groups of users. • View and manage component metadata. • Host internal customized items not available in remote repositories.
  • 16. Introduction Maven “Maven is a software management and comprehension tool based on the concept of Project Object Model (POM) which can manage project build, reporting, and documentation from a central piece of information”. POM (Project Object Model): “As a fundamental unit of work in Maven, POM is an XML file that contains information about project and configuration details used by Maven to build the project”.
  • 17. Objectives and Characteristics of Maven • Maven is more than just Build Tool • Maven was built considering certain objectives • Maven Provides: • Easy Build Process • Uniform Build System • Quality Project Information • Guidelines for Best Practices Development • Achieved Characteristics: • Visibility • Reusability • Maintainability
  • 18. Comparison with ANT 1. One level above ANT 2. Higher level of reusability between builds 3. Faster turn around time to set up a powerful build 4. Project website generation 5. Less maintenance 6. Repository management ANT MAVEN Target build.xml Goal pom.xml
  • 19. Main features of Maven Build-Tool Dependency Management Tool Documentation Tool
  • 20. Project creation in Maven mvn archetype:generate -DgroupId = com.mycompany.app -DartifactId = my-app -DarchetypeArtifactId = maven-archetype-quickstart -DinteractiveMode = false
  • 21. Contents of the created project  POM  source tree for your application's sources  source tree for your test sources
  • 22. Standard directory layout created project src/main/java Application/Library sources src/main/resources Application/Library resources src/main/filters Resource filter files src/main/assembly Assembly descriptors src/main/config Configuration files src/main/scripts Application/Library scripts src/main/webapp Web application sources src/test/java Test sources src/test/resources Test resources src/test/filters Test resource filter files src/site Site LICENSE.txt Project's license NOTICE.txt Notices and attributions required by libraries that the project depends on README.txt Project's readme
  • 23. Components of POM file • Metadata: Location of Directories, Developers/Contributors, Dependencies, Repositories • Dependencies (Transitive Dependencies), Inheritance, and Aggregation • Key Elements  Project  Model Version  Group ID  Packaging  Artifact ID  Version  Name  URL  Description
  • 24. Structure of POM file in maven <project> <modelVersion> 4.0.0 </modelVersion> <groupId> com.mycompany.app </groupId> <artifactId> my-app </artifactId> <packaging> jar </packaging> <version> 1.0-SNAPSHOT </version> <name> Maven Quick Start Archetype </name> <url> http://maven.apache.org </url> <dependencies> <dependency> <groupId> junit </groupId> <artifactId> junit </artifactId> <version> 4.8.2 </version> <scope> test </scope> </dependency> </dependencies> </project>
  • 25. Structure of BUILD file in ANT <project default = "compile"> <property name = "classesdir = " " value = "..."/> <property name = "libdir" value = "..."/> <target name = "compile"> <mkdir dir = "${classesdir}"/> <javac destdir = "${classesdir}"> <src> <pathelement location = "src/main/java"/> </src> <classpath> <fileset dir = "${libdir}"> <include name = "*.jar"/> </fileset> </classpath> </javac> </target> </project>
  • 27. Installing and Configuring Maven sudo mkdir maven cd maven sudo wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0- bin.tar.gz sudo tar xavf apache-maven-3.6.0-bin.tar.gz export PATH=$PATH:/home/vagrant/maven/apache-maven-3.6.0/bin/ mvn --version
  • 28. Configuring Maven Nexus Repository Manager Maven Configuration To use repository manager with Apache Maven, you need to first configure Maven to check the repository manager instead of the default, built-in connection to the Central Repository. To do this, add a mirror configuration and override the default configuration for the central repository in your settings.xml at ~/maven/apache-maven-3.6.0/conf. <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-proxy-test/</url> settings.xml
  • 29. Configuring Maven Make a maven project Create a Maven project also known as a Project Object Model or POM. We’ll use this POM later to cache new components from Maven Central to your proxy repository. 1. Navigate to your user directory and then create directory “maven-test”. 2. Open your new directory by changing to maven-test. 3. Create a POM file (pom.xml) with given contents. pom.xml <project> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>nexus-proxy</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> </dependency> </dependencies> </project>
  • 32. Maven Proxy Repository Maven Proxy repository A proxy repository is a repository that is linked to a remote repository, such as the Central Repository to cache to components. When you search for component for first time, it is retrieved from Central and cached in the repository manager. If you search for that same component again, it will be found in local storage. This eliminates the need to go to the Central Repository and reduces bandwidth and time needed to retrieve the components you need. Create a new Maven proxy in the Nexus Repository Manager UI by following below steps. 1. Open the Nexus Repository Manager user interface. 2. Click Administration in the top navigation menu, and then select Repositories. 3. Click Create repository, and then choose the maven2 (proxy) recipe from the list. 4. Add the following text in the required fields: • Name: maven-proxy-test • Remote storage URL: https://repo1.maven.org/maven2 5. Click Create repository to complete the form. The repository manager is now configured to proxy Maven Central.
  • 33. Maven Proxy Repository Cache New Components from Maven Central to the Proxy 1. In your terminal, navigate to the POM file you created, and run the command mvn package. Your build is ready when you get a “BUILD SUCCESS” message. 2. In Nexus Repository Manager, click Browse in the main toolbar and then select Browse from the left-side menu. 3. Now navigate to maven-proxy-test. You'll see the test components you proxied for the Maven format during the previous steps. 4. Click on a component name to review its details.
  • 34. Maven Hosted Repository Maven Hosted repository A hosted repository is a repository that act as the authoritative location for your in-house components and store the components not necessarily available at central repository. Now add following steps to your settings.xml and pom.xml settings.xml pom.xml <project> ... <distributionManagement> <repository> <id>nexus</id> <name>maven-releases</name> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus</id> <name>maven-snapshots</name> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> <servers> <server> <id>nexus</id> <username>admin</username> <password>*******</password> </server> </servers>
  • 35. Maven Hosted Repository Run Snapshot builds 1. In your terminal, navigate to your POM, and run the build with mvn clean deploy. Your build is ready when you see a “BUILD SUCCESS” message. 2. In Nexus Repository Manager, click Browse in the main toolbar and then select Browse from the left-side menu. 3. Of your repositories, choose maven-snapshots. You'll see the test components from your Maven Snapshots build. 4. Click on a component name to review its details
  • 36. Maven Hosted Repository Run Release builds 1. From your POM file, release “SNAPSHOT” from the version tag as shown. 2. Navigate to your POM, and run the build with mvn clean deploy. Your build is ready when you see a “BUILD SUCCESS” message. 3. In Nexus Repository Manager, click Browse in the main toolbar and then select Browse from the left-side menu. 4. Now choose maven-releases. You'll see the test components from your Maven Releases build. 5. Click on a component name to review its details:
  • 37. Maven Group Repository Maven Group repository A proxy repository is a one-stop location where developers can collaborate on a project with all available components assigned to it. If you’re an administrator you can dynamically add repositories without updating developer settings. If you’re a developer you can access the contents of the group by sending requests directly to the repository manager. NOTE: It’s important to note that a group doesn’t store components. You cannot publish or deploy components directly to it. Groups just aggregate content from other repositories. If you want to modify components in a group repository, publish those changes to a hosted repository included in the group. Create a new Maven group in the Nexus Repository Manager UI by following below steps. 1. Select Repositories, then Create repository. 2. Choose the maven2 (group) recipe. 3. Fill out the form, using maven-all as the Name. 4. Drag and drop the Available proxy and hosted repositories you created in the previous lesson to the Member field 5. Click Save to complete the form. 6. Make a note of the this group URL from the Repositories screen. The repository URL for this example is: http://localhost:8081/repository/maven-all.
  • 38. Maven Group Repository Customize your Settings for Group Access Customize your seetings.xml for group repository access in the Nexus Repository Manager UI by following below steps. 1. Copy the group URL from nexus repository and paste the same in settings.xml in into the mirror config section similar to the sample settings file below: <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-all/</url> 2. Run the maven build for maven-test project using “mvn install”. 3. To locate all grouped components go to the Browse from Administration and select maven-all option.
  • 39. Setting up npm using Nexus repository
  • 40. Setting up ruby gems using Nexus repository
  • 42. Setting up yum and .NET package repositories using NuGet
  • 47. Restore from Backup Follow the below steps to restore data from backup. 1. Stop Nexus Repository Manager 2. Remove the following directories from $data-dir/db • accesslog • analytics • audit • component • config • security 3. Go to the location where you stored the exported databases 4. Copy the corresponding .bak files to $data-dir/restore-from-backup for restoration (Note: For version 3.10.0 or earlier use $data-dir/backup as the restore location) 5. Restart Nexus Repository Manager 6. You can verify the restoration is complete by viewing the fully-restored databases previously removed from $data-dir/nexus3/db.