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
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:8
Expose 8080
ADD target/studentapp-2.5-SNAPSHOT.jar studentapp-2.5-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/studentapp-2.5-SNAPSHOT.jar"]
8 changes: 6 additions & 2 deletions WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ div.ex {
<form action="registrationController" method="post">
<table style="with: 50%">
<tr>
<td>Student Name</td>
<td>Student Full Name</td>
<td><input type="text" name="fullname"/></td>
</tr>
<tr>
<td>Student Address</td>
<td>Student Father Name</td>
<td><input type="text" name="fullname"/></td>
</tr>
<tr>
<td>Student Permanent Address</td>
<td><input type="text" name="address"/></td>
</tr>
<tr>
Expand Down
19 changes: 19 additions & 0 deletions deploy-for-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

### Remove old war files
rm -rf /tomcat/test/webapps/student*

### Copy the war file
cp /var/lib/jenkins/workspace/sample-test1/target/student*.war /tomcat/test/webapps/student.war

sleep 20

RESPONSE=$(curl -s -I http://localhost:8082/student/index.jsp | head -1 | awk '{print $2}')
echo RESPONSE = $RESPONSE
if [ "$RESPONSE" != 200 ]; then
echo "Response from student APP is not OK"
exit 1
fi

URL=$(cat /var/lib/jenkins/jobs/sample-test1/builds/$BUILD_NUMBER/log | grep Uploaded | grep war |xargs -n1 | grep ^http)
sed -i -e "s|URL-LOC|$URL|" deploy.yml
17 changes: 17 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: Deploy student app in PROD
hosts: all
become: yes
vars:
URL: URL-LOC
tasks:
- name: Remove the old war files
file:
name: "/opt/apache-tomcat-9.0.1/webapps/{{item}}"
state: absent
with_items:
- student
- student.war
- name: Download war file
get_url:
url: "{{URL}}"
dest: /opt/apache-tomcat-9.0.1/webapps/student.war
2 changes: 2 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
10.128.0.3
####
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.jdevs</groupId>
<artifactId>studentapp</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.5-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
Expand All @@ -29,12 +29,12 @@
<repository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://10.128.0.9:8081/repository/maven-releases/</url>
<url>http://10.128.0.10:8081/repository/student-rel/</url>
</repository>
<snapshotRepository>
<id>deployment</id>
<name>Internal Snapshot Releases</name>
<url>http://10.128.0.9:8081/repository/maven-snapshots/</url>
<url>http://10.128.0.10:8081/repository/student-snap/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
Expand Down
31 changes: 30 additions & 1 deletion src/com/srk/dao/StudentDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@ public class StudentDAO {
return con;
}*/


/*public static Connection getConnection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
}catch(Exception e){System.out.println(e);}
return con;
}*/


/*public static Connection getConnection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
}catch(Exception e){System.out.println(e);}
return con;
}*/


/*public static Connection getConnection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
}catch(Exception e){System.out.println(e);}
return con;
}*/
public static Connection getConnection() throws Exception {
Connection conn=null;
Context initContext = new InitialContext();
Expand Down Expand Up @@ -130,4 +159,4 @@ public static List<Student> getAllStudents(){

return students;
}
}
}