Tuesday 7 September 2021

Nexus Maven Repository & Setup

Steps to Configure Nexus Maven & Application integration

PART - A Nexus Maven Creation


1. Create User Account in Nexus

2. Create a Maven Group repository

3. Add existing  maven host & proxy repositories into the new maven repo

4. Make Sure , enable the HTTP user authentication for Maven Central Repository part of newly created Group Repository.

5. Verify the Repository  Access using the URL



PART - B  Maven Config files creation

1. Create Maven Master Password Creation

$ mvn --encrypt-master-password <PASSWORD>

2. Save the result into a file "settings-security.xml" 
<settingsSecurity>
<master>{XOZTXCnPjDsHo1jxbPOEdjSCkMamoy4fgdfYej7588I=}</master>
</settingsSecurity>
Notes:
If you like to keep the password somewhere USB to plug & Build 
Store the file into USB drive specific folder 
like '/Volumes/mySecureUsb/secure/settings-security.xml' & use it.

<settingsSecurity>
    <relocation>/Volumes/mySecureUsb/secure/settings-security.xml</relocation></settingsSecurity>

3. Using Master password encrypt Repository Password to be used in pom.xml for build

For Example :

Repository URL : https://www.tamilcloud.com:8443/repository/maven-central/
Repository User Name : tamilarasan
Repository Password  : abcdefgh => needs to be encrypted to be used in CI CD pipeline

$ mvn --encrypt-password "abcdefgh" -s Settings.xml -Dsettings.security=settings-security.xml

4. Update the encrypted password into Settings.xml in server password Section

<servers>
<server>
<id>nexus</id>
<username>tamilarasan</username>
<password>{zVwvg21CdkIHM9hA5GsKv+9rzIZlslT3qAmkxcvh+xA=}</password> <!-- Encrypted Repo Password -->
</server>
</servers>

5. Update the Application pom.xml with nexus repository details.

<distributionManagement> <repository> <id>nexus</id> <name>Releases</name> <url>http://www.tamilcloud.com:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus</id> <name>Snapshot</name> <url>http://www.tamilcloud.com:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>

6. Compile and build with Settings.xml & settings-Security.xml

mvn -s settings.xml -Dsettings.security=settings-security.xml clean compile package deploy

7. Verify build result.

8. Verify the Nexus repository

Source Code : Click here

Done :)












No comments:

Post a Comment