Build a repository use Nexus Repository

#Introduction

In this tutorial, How to build a repository use nexus repository. In the previous post, I have installed Nexus repository here.

Maven build a repository with Nexus Repository

Hosted repository

Create a new repository as below:

Name: maven2-hosted

proxy repository

Create a new proxy repository as below

  • Name: maven2-proxy
  • Remote storage: https://repo1.maven.org/maven2/

group repository

Create a new group repository as below

  • Name: maven2-group
  • Members: maven2-private-example maven2-proxy-example

How to get package from Nexus Repository

I will Create a maven project in eclipse.

Edit the pom.xml file. I will get a poi package.

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>nexus-devopsroles</groupId>
  <artifactId>maven2</artifactId>
  <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>poi</groupId>
            <artifactId>poi</artifactId>
            <version>2.5.1</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven-group</id>
            <name>My Maven Group Repository</name>
            <url>http://192.168.3.4:8081/repository/maven2-group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>maven-group</id>
            <name>My Maven Group Repository</name>
            <url>http://192.168.3.4:8081/repository/maven2-group/</url>
        </pluginRepository>
    </pluginRepositories>

    <distributionManagement>
        <repository>
            <id>maven2-private-example</id>
            <name>My Maven Hosted Repository</name>
            <url>http://192.168.3.4:8081/repository/maven2-private-example/</url>
        </repository>
    </distributionManagement>
</project>

Maven does not download packages that have already been acquired from the web, so packages are not stored in the proxy repository

NPM build a repository with Nexus Repository

Hosted repository

Create a new repository as below

Name: npm-hosted

proxy repository

Create a new proxy repository as below

group repository

Create a new group repository as below

  • Name: npm-group
  • Members: npm-proxy-example npm-private-example

How to get the package

Create the following two files in any directory

.npmrc file

email=HuuPV@devopsroles.com
always-auth=true
_auth=YWRtaW46YWRtaW4xMjMxMjM=

registry=http://192.168.3.4:8081/repository/npm-proxy/

package.json file

{
  "name": "npm-hosted",
  "version": "1.0.0",
  "description": "for nexus3",
  "dependencies": {
  }
}

Authentication information generated by the following method

echo -n 'admin:admin123123' | openssl base64

Output

YWRtaW46YWRtaW4xMjMxMjM=

Get the required packages from a repository on the Internet via the Nexus3 proxy repository. By acquiring via the proxy repository, it is automatically saved to Nexus3 as well as download.

npm install --save <package name>
# Example
npm install --save bower

As a result of executing the above command, the package is saved.

Conclusion

You have Build a repository use Nexus Repository. I hope will this your helpful. Thank you for reading the DevopsRoles page!

, ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.