0% found this document useful (0 votes)
12 views19 pages

Sonar Nexus-Full Document

The document outlines the setup and configuration of Sonar Nexus as a repository manager, detailing its benefits and features such as centralized artifact management and security integration. It provides step-by-step instructions for launching an AWS instance, installing Nexus, and configuring it for use, including creating a repository. Additionally, it describes the process of setting up a Jenkins instance, creating a pipeline job, and uploading artifacts to the Nexus repository.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views19 pages

Sonar Nexus-Full Document

The document outlines the setup and configuration of Sonar Nexus as a repository manager, detailing its benefits and features such as centralized artifact management and security integration. It provides step-by-step instructions for launching an AWS instance, installing Nexus, and configuring it for use, including creating a repository. Additionally, it describes the process of setting up a Jenkins instance, creating a pipeline job, and uploading artifacts to the Nexus repository.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Aws & devops by veera nareshit

SONAR NEXUS
Sonar Nexus is a repository manager. It allows you to proxy, collect, and
manage your dependencies so that you are not constantly juggling a
collection of JARs. It makes it easy to distribute your software. Internally,
you configure your build to publish artifacts to Lifecycle and they then
become available to other developers.
 Nexus supports various package formats such as Maven, npm,
NuGet, PyPI, and more.

 Benefits include centralized artifact management, improved build


performance, dependency security, and reduced risk of external
repository downtime.

 A repository proxy in Nexus serves as a cache for remote


repositories. It fetches and stores artifacts from external sources,
improving performance and reliability.

 Nexus integrates with vulnerability scanning tools, enforces access


controls, and facilitates the use of trusted artifacts, reducing
security risks.

 Repository groups combine multiple repositories into a single


virtual repository. This simplifies configuration and provides a
unified view of artifacts.

 Repository health checks monitor the state of repositories,


identifying issues and ensuring they are properly maintained.

 Nexus OSS is the free, open-source version, while Nexus Pro is


the commercial version with advanced features like support for
staging and promotions.

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Preq :
Instance type : t2 medium
Ami : Amazon Linux 2 Kernel 5.10 AMI 2.0.20240412.0 x86_64 HVM
gp2
Security group : allow all traffic (inbound )
Ebs volume : 30gb

Launch an Instance.
Now create file :

Aws & devops by veera nareshit


Aws & devops by veera nareshit

vi sonar nexus.sh
sudo yum update -y

sudo yum install wget -y

sudo yum install java-1.8.0-openjdk.x86_64 -y

sudo mkdir /app && cd /app

sudo wget -O nexus.tar.gz https://download.sonatype.com/nexus/3/latest-unix.tar.gz

sudo tar -xvf nexus.tar.gz

sudo mv nexus-3* nexus

sudo adduser nexus

sudo chown -R nexus:nexus /app/nexus

sudo chown -R nexus:nexus /app/sonatype-work

sudo echo "run_as_user="nexus"" > /app/nexus/bin/nexus.rc

sudo tee /etc/systemd/system/nexus.service > /dev/null << EOL

[Unit]

Description=nexus service

After=network.target

[Service]

Type=forking

LimitNOFILE=65536

User=nexus

Group=nexus

ExecStart=/app/nexus/bin/nexus start

ExecStop=/app/nexus/bin/nexus stop

User=nexus

Restart=on-abort

[Install]

WantedBy=multi-user.target

EOL

sudo chkconfig nexus on

sudo systemctl start nexus

sudo systemctl status nexus

Aws & devops by veera nareshit


Aws & devops by veera nareshit

save the file and run this command


sh sonar nexus.sh

To Login Sonar Nexus public ip: 8081

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Now click on Sign in

For Sign in we required


UserName : admin
Password: (sudo cat /app/sonatype-work/nexus3/admin.password )-
copy paste in nexus instance

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Click on Next . Enter your custom password

Configure Anonymous Access


 Select Disable anonymous access

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Click on Next

Click on finish.
See left side Browse option click on it.

Aws & devops by veera nareshit


Aws & devops by veera nareshit

On top Setting option select – > Repositories

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Repositories -> (+)Create Repository

After click on create repository - >select maven2(hosted)

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Given Repository Name – Anything (netflix)

See Deployment policy -> Allow redeploy

Now press Create Repository button.

Aws & devops by veera nareshit


Aws & devops by veera nareshit

See my repository created.

As we how create Jenkins instance

Preq :
Instance type : t2 medium
Ami : Amazon Linux 2 Kernel 5.10 AMI 2.0.20240412.0 x86_64 HVM
gp2
Security group : allow all traffic (inbound)
Ebs volume : 30gb
Launch an jenkins instance.
Created file
vi Jenkins.sh

#STEP-1: INSTALLING GIT JAVA-1.8.0 MAVEN

yum install git java-1.8.0-openjdk maven -y

#STEP-2: GETTING THE REPO (jenkins.io --> download -- > redhat)

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

#STEP-3: DOWNLOAD JAVA11 AND JENKINS

Aws & devops by veera nareshit


Aws & devops by veera nareshit

amazon-linux-extras install java-openjdk11 -y

yum install jenkins -y

update-alternatives --config java

#STEP-4: RESTARTING JENKINS (when we download service it will on stopped state)

systemctl start jenkins.service

systemctl status jenkins.service

save it and run file with this command


sh Jenkins.sh

Press 2 then enter

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Now login to Jenkins Instance then go to manage Jenkins – Plugins

Then Available plugin –Nexus Artifact uploader

After Installed plugin.

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Now create pipeline job.


Name it and press ok.

After creating pipeline job run this script .


pipeline {

agent any

stages {

stage('clone') {

steps {

git 'https://github.com/saridiramesh/jenkins-java-project.git'

stage('artifact') {

steps {

sh 'mvn clean package'

Aws & devops by veera nareshit


Aws & devops by veera nareshit

From the above script artifact was created .


Go to this path and check .war
cd /var/lib/jenkins/workspace/netflix/target
Now again in same pipeline press configure .
Pipeline syntax: Nexus artifact uploader

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Add sonar nexus credentials

Go github – repository we find this file pom.xml these values available should
enter below

Repository : sonar nexus previous was created by us that one(netflix).

File : you will find here can see .war ( cd


/var/lib/jenkins/workspace/netflix/target)

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Then write like this target/****.war(where * indicate file name should


mention in place )

Copy it paste in pipeline script.


pipeline {

agent any

stages {

stage('clone') {

steps {

git 'https://github.com/saridiramesh/jenkins-java-project.git'

stage('artifact') {

steps {

sh 'mvn clean package'

stage('artifact uploader') {

steps {

nexusArtifactUploader artifacts: [[artifactId: 'NETFLIX', classifier: '', file: 'target/NETFLIX-


1.2.2.war', type: 'war']], credentialsId: '2fa20b97-26f4-40b8-9bb3-b12c80b8cdfd', groupId:
'in.RAHAM', nexusUrl: '15.207.14.26:8081', nexusVersion: 'nexus3', protocol: 'http', repository:
'netflix', version: '1.2.2'

Apply and Save .Then build now.

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Now go to Sonar Nexus login with username and password.

Click on own Repository .

We see Artifact uploaded .war as below :

Aws & devops by veera nareshit


Aws & devops by veera nareshit

Aws & devops by veera nareshit

You might also like