0% found this document useful (0 votes)
19 views

Cicd in Jenkins

Uploaded by

swaleheen08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Cicd in Jenkins

Uploaded by

swaleheen08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DEVELOPING

F A TESTING

A
CI/CD S T
U
M
B Y
P S
V O
DE
TOOLS USED

A
1 GIT
Agenda F
2
T A
MAVEN
DEPLOY AN APPLICATION IN S
U JENKINS
M
TOMCAT WEB SERVER USING CI/CD
3

B Y
GIT: To maintain the source code.
P S 4 SONAR

O
MAVEN: To build the source code.

V
SONAR: For code quality test.

E
NEXUS: To store the artifact.
5 NEXUS
D
TOMCAT: Webserver to deploy an application.
JENKINS: To Integrate all the tools.

6 TOMCAT
PUSH
CODE

F A
T A
U S
M
B Y WAR
S
PBUILD
V O
DE
WAR WAR
DEPLOYMENT:
The term Deployments refers the installation of a Web-Application
on WebApplication server.
F A
T A
WHY DEPLOYMENT:
U S
The main reasons of the deployment are:
M
Adding New Features to the Application.
Removing the Bugs. B Y
Enhancing the New Features.
P S
Improving the Performance.
V O
E
Breaking Large Applications to MicroServices.

D
NEED FOR DEPLOYMENT:
We need to have Infra Setup.
New Release of code.
F A
Involvement of Dev, QA and DevOps Team.
T A
S
Creating New Db’s If needed.
Approval from RM (in case of New release).
U
PRECAUTIONS: M
Y
Band DataBases.
P
Need To Provide Isolated Environments S
Need to take Backups of the Current Builds
for Dev, Test and Prod.
Can be able to do RollBack if theO
V
Deployment fails in some cases.

D E
Make sure we are deploying the correct env and Client Application Servers.
STEP-1:
LAUNCH 4 INSTANCES WITH SAME PEM FILE
1. JENKINS: T2.MICRO
F A
2. TOMCAT: T2.MICRO
T A
3. SONAR: T2.MEDIUM (20 GB OF EBS VOLUME)
4. NEXUS: T2.MEDIUM (20 GB OF EBS VOLUME)
U S
M
Y
SETUP SERVICES IN THEIR RESPECTIVE SERVERS.
B
STEP-2:
P S
V
LOGIN INTO JENKINS DASHBOARD O AND INSTALL THESE FOLLOWING PLUGINS

D
1. SONAR SCANNER: to
E
scan the code
2. NEXUS ARTIFACTORY UPLOADED: to store the files in nexus
3. SSH AGENT: To send the files from one server to another server
STEP-3:
Create a jenkins pipeline job and write a Jenkins file for deploy a web application,
usually we have 2 types of pipelines,
F A
scripted
T A
S
declarative

U
M
Here i am using scripted pipeline for the Jenkins file

STAGE-1 : GET THE CODE FROM GITHUB TOB


Y
CI-SERVER
————————————————————— S
node {
O P
stage ("code") {
E V
D
git "https://github.com/devops0014/one.git"
}
}
STAGE-2 : BUILD THE SOURCE CODE:

GO TO MANAGE JENKINS >> GLOBAL TOOL CONFIGURATION >> MAVEN


F A
A
ADD INSTALLER WITH THE NAME OF maven WITH VERISON (3.8.6)
—————————————————————————————————————
S T
U
M
node {
stage ("build"){

B Y
def mavenHome = tool name: "maven", type: "maven"
S
def mavenCMD = "${mavenHome}/bin/mvn"
P
}
V O
sh "${mavenCMD} clean package"

}
DE
STAGE-3 : SCAN THE SOURCE CODE:

LOGIN INTO SONAR


GO TO MY ACCOUNT >> SECURITY >> ENTER A TOKEN NAME AND GENERATE A TOKEN
NOW INTEGRATE THE SONAR TO JENKINS
F A
A
MANAGE JENKINS >> CONFIGURE SYSTEM >> SONAR SERVER :
NAME: mysonar
Url: PublicIP:9000/
S T
credentials: —— (username with secretkey)
U
—————————————————————————————————————
M
node {
stage("Test") {
B Y
withSonarQubeEnv('mysonar')
{
P S
V O
def mavenHome = tool name: "maven", type: "maven"

DE
def mavenCMD = "${mavenHome}/bin/mvn"
sh "${mavenCMD} sonar:sonar"
}
}
}
STAGE-4 : UPLOAD WAR FILE INTO ARTIFACTORY:

CREATE A REPO IN NEXUS :


Name: mustafa-releases
formar: maven2 hosted
F A
Version policy: releases
Deployment policy: allow redeploy
T A
INSTALL NEXUS ARTIFACTORY UPLOAD PLUGIN

U S
To GENERATE THE PIPELINE SYNTAX, WE NEED TO USE NEXUS ARTIFACTORY UPLOADER IN PIPELINE
SYNTAX AND GIVE ALL INPUTS AND GENERATE PIPELINE SYNTAX
M
—————————————————————————————————————

B Y
node {
stage ("upload") {
P S
O
nexusArtifactUploader artifacts: [[artifactId: 'myweb', classifier: '', file: 'target/myweb-8.3.5.war', type:
V
E
'.war']], credentialsId: '4949746a-34ae-4d80-acaa-a73815fda645', groupId: 'in.javahome', nexusUrl:

D
'18.117.135.27:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'mustafa-releases', version: '8.3.5'
}
}
STAGE-5 : DEPLOY THE APPLICATION INTO TOMCAT WEB SERVER:

AND USE PIPELINE SYNTAX

—————————————————————————————————————
F A
node {
T A
stage ("deploy") {
sshagent(['25e8d3a9-62fd-478b-8e4d-2ee40674436f']) {
US
M
sh "scp -o StrictHostKeyChecking=no /var/lib/jenkins/workspace/pipeline-1/target/myweb-8.3.5.war

}
B Y
[email protected]:/opt/apache-tomcat-9.0.73/webapps"

}
}
P S
V O
D E

You might also like