Cicd in Jenkins
Cicd in Jenkins
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
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:
DE
def mavenCMD = "${mavenHome}/bin/mvn"
sh "${mavenCMD} sonar:sonar"
}
}
}
STAGE-4 : UPLOAD WAR FILE INTO ARTIFACTORY:
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:
—————————————————————————————————————
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