diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c643a9a3 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/WebContent/index.jsp b/WebContent/index.jsp index 9fa0ccc5..5d19d508 100644 --- a/WebContent/index.jsp +++ b/WebContent/index.jsp @@ -20,11 +20,15 @@ div.ex {
- + - + + + + + diff --git a/deploy-for-test.sh b/deploy-for-test.sh new file mode 100644 index 00000000..6002e6cd --- /dev/null +++ b/deploy-for-test.sh @@ -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 diff --git a/deploy.yml b/deploy.yml new file mode 100644 index 00000000..af91b7b8 --- /dev/null +++ b/deploy.yml @@ -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 diff --git a/inventory b/inventory new file mode 100644 index 00000000..619ecb45 --- /dev/null +++ b/inventory @@ -0,0 +1,2 @@ +10.128.0.3 +#### diff --git a/pom.xml b/pom.xml index 8c86fccc..f9b4b08d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0com.jdevsstudentapp - 2.1.1-SNAPSHOT + 2.5-SNAPSHOTwar src @@ -29,12 +29,12 @@ deployment Internal Releases - http://10.128.0.9:8081/repository/maven-releases/ + http://10.128.0.10:8081/repository/student-rel/ deployment Internal Snapshot Releases - http://10.128.0.9:8081/repository/maven-snapshots/ + http://10.128.0.10:8081/repository/student-snap/ diff --git a/src/com/srk/dao/StudentDAO.java b/src/com/srk/dao/StudentDAO.java index eb1db370..3b4b2226 100644 --- a/src/com/srk/dao/StudentDAO.java +++ b/src/com/srk/dao/StudentDAO.java @@ -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(); @@ -130,4 +159,4 @@ public static List getAllStudents(){ return students; } -} \ No newline at end of file +}
Student NameStudent Full Name
Student AddressStudent Father Name
Student Permanent Address