7.5. Encrypting Nexus Password & Configuring with Maven:
Step-1: To do this, must create a master password first and store this master password in a security-settings.xml file in ~/.m2/settings-security.xml.
To configure encrypted passwords, create a master password by running mvn -emp or mvn --encrypt-master-password followed by your master password.
[cicdapiadmin@cicd opt] $ mvn -emp password
{bgbxjnxj46bbjFDGnjjnJJNj/0FHvhbjnk9/PVhyyuhH=}
Maven prints out an encrypted copy of the password to standard out. Copy this encrypted password and paste it into a ~/.m2/settings-security.xml file (settings-security.xml file has to create first)
[cicdapiadmin@cicd opt]$ sudo vi /opt/maven/conf/.m2/settings-security.xml
Update Master password like this
{bgbxjnxj46bbjFDGnjjnJJNj/0FHvhbjnk9/PVhyyuhH=}
Step-2: Now use this master password to encrypt passwords stored in Maven Settings
(~/.m2/settings.xml).
To encrypt a password with the master password, run mvn -ep or mvn --encrypt-password.
[cicdapiadmin@cicd opt] $ mvn -ep passwordtoUse
{/nj68njbjUhu/jbJIMLM56yt8/FRDtj=bbjn/=}
Copy the above encrypted password printed from the output of mvn -ep and paste it into your Maven Settings.
[cicdapiadmin@cicd opt] $ sudo vi /opt/maven/conf/settings.xml
Here Update Username, Password and Server details of Nexus in Servers path as mentioned below:
nexus deployer {/nj68njbjUhu/jbJIMLM56yt8/FRDtj=bbjn/=}
Now Nexus password encrypted and configured with Maven Successfully
7.6. How to relocate nexus blobstorage:
Moving blob storage to free disk space.
Following commands will mount, backup and move blob storage location.
[nexus@cicd opt] # cd /sonatype-work/nexus3/blobs/backup/date of backup
[nexus@cicd dateofbackup] #mv _default/ /mnt/resource/ sonatype-work/nexus3/blobs/backup/date of backup
[nexus@cicd dateofbackup] # cd /mnt/resource/sonatype-work/nexus3/blobs/backup/date of backup
[nexus@cicd dateofbackup] # tar -xcvf _default.tar.gz _default
[nexus@cicd dateofbackup] # rm -rf _default
Now restart the nexus server once and check the blobstorage.
To automate this as a scheduled we can create cleanup policy and compact blob storage tasks.