0% found this document useful (0 votes)
3 views11 pages

Deploy an Application in Tomcat web Server using CI_CD

The document outlines a CI/CD process for deploying a web application on a Tomcat web server. It details the steps involved, including setting up instances, configuring Jenkins with necessary plugins, creating a Jenkins pipeline for code retrieval, building, scanning, uploading artifacts, and deploying the application. Precautions for deployment and the need for collaboration among teams are also emphasized.

Uploaded by

Venkat Gowda
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)
3 views11 pages

Deploy an Application in Tomcat web Server using CI_CD

The document outlines a CI/CD process for deploying a web application on a Tomcat web server. It details the steps involved, including setting up instances, configuring Jenkins with necessary plugins, creating a Jenkins pipeline for code retrieval, building, scanning, uploading artifacts, and deploying the application. Precautions for deployment and the need for collaboration among teams are also emphasized.

Uploaded by

Venkat Gowda
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

TESTING

DEVELOPING

CI/CD
Agenda
2
DEPLOY AN APPLICATION IN
TOMCAT WEB SERVER USING CI/CD
PUSH
CODE

BUILD

WAR
DEPLOYMENT:
The term Deployments refers the installation of a Web-Application
on WebApplication server.

WHY DEPLOYMENT:
The main reasons of the deployment are:
Adding New Features to the Application.
Removing the Bugs.
Enhancing the New Features.
Improving the Performance.
Breaking Large Applications to MicroServices.
NEED FOR DEPLOYMENT:
We need to have Infra Setup.
New Release of code.
Involvement of Dev, QA and DevOps Team.
Creating New Db’s If needed.
Approval from RM (in case of New release).

PRECAUTIONS:
Need to take Backups of the Current Builds and DataBases.
Need To Provide Isolated Environments for Dev, Test and Prod.
Can be able to do RollBack if the Deployment fails in some cases.
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
2. TOMCAT: T2.MICRO
3. SONAR: T2.MEDIUM (20 GB OF EBS VOLUME)
4. NEXUS: T2.MEDIUM (20 GB OF EBS VOLUME)

SETUP SERVICES IN THEIR RESPECTIVE SERVERS.

STEP-2:
LOGIN INTO JENKINS DASHBOARD AND INSTALL THESE FOLLOWING PLUGINS

1. SONAR SCANNER: to 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,
scripted
declarative

Here i am using scripted pipeline for the Jenkins file

STAGE-1 : GET THE CODE FROM GITHUB TO CI-SERVER


—————————————————————
node {
stage ("code") {
git "https://github.com/devops0014/one.git"
}
}
STAGE-2 : BUILD THE SOURCE CODE:

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


ADD INSTALLER WITH THE NAME OF maven WITH VERISON (3.8.6)
—————————————————————————————————————

node {
stage ("build"){
def mavenHome = tool name: "maven", type: "maven"
def mavenCMD = "${mavenHome}/bin/mvn"
sh "${mavenCMD} clean package"
}
}
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
MANAGE JENKINS >> CONFIGURE SYSTEM >> SONAR SERVER :
NAME: mysonar
Url: PublicIP:9000/
credentials: —— (username with secretkey)
—————————————————————————————————————
node {
stage("Test") {
withSonarQubeEnv('mysonar')
{
def mavenHome = tool name: "maven", type: "maven"
def mavenCMD = "${mavenHome}/bin/mvn"
sh "${mavenCMD} sonar:sonar"
}
}
}
STAGE-4 : UPLOAD WAR FILE INTO ARTIFACTORY:

CREATE A REPO IN NEXUS :


Name: sanjay-releases formar:
maven2 hosted Version policy:
releases
Deployment policy: allow redeploy
INSTALL NEXUS ARTIFACTORY UPLOAD PLUGIN
To GENERATE THE PIPELINE SYNTAX, WE NEED TO USE NEXUS ARTIFACTORY UPLOADER IN PIPELINE
SYNTAX AND GIVE ALL INPUTS AND GENERATE PIPELINE SYNTAX
—————————————————————————————————————

node {
stage ("upload") {
nexusArtifactUploader artifacts: [[artifactId: 'myweb', classifier: '', file: 'target/myweb-8.3.5.war', type:
'.war']], credentialsId: '4949746a-34ae-4d80-acaa-a73815fda645', groupId: 'in.javahome', nexusUrl:
'18.117.135.27:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'sanjay-releases', version: '8.3.5'
}
}
STAGE-5 : DEPLOY THE APPLICATION INTO TOMCAT WEB SERVER:

AND USE PIPELINE SYNTAX

—————————————————————————————————————

node {
stage ("deploy") {
sshagent(['25e8d3a9-62fd-478b-8e4d-2ee40674436f']) {
sh "scp -o StrictHostKeyChecking=no /var/lib/jenkins/workspace/pipeline-1/target/myweb-8.3.5.war
[email protected]:/opt/apache-tomcat-9.0.73/webapps"
}
}
}

You might also like