Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM tomcat:9.0

# remove default apps
RUN rm -rf /usr/local/tomcat/webapps/*

# copy WAR
COPY target/LoginWebApp.war /usr/local/tomcat/webapps/ROOT.war

EXPOSE 8080

CMD ["catalina.sh","run"]
107 changes: 63 additions & 44 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,66 @@

pipeline {
agent {
label {
label "built-in"
customWorkspace "/data/project-myapp"

}
}

stages {

stage ('CLEAN_OLD_M2') {

steps {
sh "rm -rf /home/saccount/.m2/repository"

}

}

stage ('MAVEN_BUILD') {

steps {

sh "mvn clean package"

}


}

stage ('COPY_WAR_TO_Server'){

steps {

sh "scp -r target/LoginWebApp.war saccount@10.0.2.51:/data/project/wars"
agent none

environment {
MAVEN_HOME = "/mnt/build-tools/apache-maven-3.9.10"
PATH = "${env.MAVEN_HOME}/bin:${env.PATH}"
}

stages {

stage('Clone Git Repository') {
agent { label 'built-in' } // Master node
steps {
dir('/mnt') {
git url: 'https://github.com/Chetashree20/project.git'
}
}
}

stage('Build WAR on Master') {
agent { label 'built-in' }
steps {
dir('/mnt/project') {
sh 'rm -rf ~/.m2/repository'
sh 'mvn clean package'
stash name: 'warfile', includes: 'target/LoginWebApp.war'
}
}
}

stage('Deploy on Slave') {
agent { label 'slave1' }
steps {
dir('/mnt/projects') {
deleteDir()
unstash 'warfile'

// Place WAR in Tomcat
sh '''
cp target/LoginWebApp.war /mnt/servers/apache-tomcat-9.0.106/webapps/
'''
}
}
}

stage('Update JSP for RDS') {
agent { label 'slave1' }
steps {
sh '''
sleep 10
sed -i 's|jdbc:mysql://localhost:3306/test", "root", "root"|jdbc:mysql://database-1.cb48gkq0ufgf.ap-south-1.rds.amazonaws.com:3306/test", "admin", "admin123456"|g' /mnt/servers/apache-tomcat-9.0.106/webapps/LoginWebApp/userRegistration.jsp
'''
}
}

}

}



}

stage('Start Tomcat on Slave') {
agent { label 'slave1' }
steps {
sh '''
/mnt/servers/apache-tomcat-9.0.106/bin/shutdown.sh || true
/mnt/servers/apache-tomcat-9.0.106/bin/startup.sh
'''
}
}
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Login Application

This project follows GitHub Flow.
All changes are made via feature branches and Pull Requests.
5 changes: 4 additions & 1 deletion src/main/webapp/success.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
You are not logged in<br/>
<a href="index.jsp">Please Login</a>
<%} else {
%>
You are Successfully logged in<br/>

%>
Welcome <%=session.getAttribute("userid")%>
<a href='logout.jsp'>Log out</a>
<%
}
%>
%>