├── .github
└── workflows
│ └── maven.yml
├── .gitignore
├── Dockerfile
├── Jenkinsfile
├── MavenWebApplication.yaml
├── appdeploy.yaml
├── docker-compose.yml
├── pom.xml
└── src
└── main
├── java
└── com
│ └── mt
│ └── services
│ └── EmployeeService.java
└── webapp
├── WEB-INF
├── mt-servlet.xml
└── web.xml
├── images
└── mithunlogo.jpg
└── jsps
└── home.jsp
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Java CI with Maven
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master,develop ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 11
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '11'
23 | distribution: 'adopt'
24 | cache: maven
25 | - name: Build with Maven
26 | run: mvn -B package --file pom.xml
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .classpath
2 | .project
3 | /.settings
4 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM tomcat:9.0-jdk11
2 | COPY target/maven-web-application.war /usr/local/tomcat/webapps/maven-web-application.war
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline{
2 |
3 | agent any
4 |
5 | tools{
6 | maven 'maven3.8.2'
7 |
8 | }
9 |
10 | triggers{
11 | pollSCM('* * * * *')
12 | }
13 |
14 | options{
15 | timestamps()
16 | buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5'))
17 | }
18 |
19 | stages{
20 |
21 | stage('CheckOutCode'){
22 | steps{
23 | git branch: 'development', credentialsId: '957b543e-6f77-4cef-9aec-82e9b0230975', url: 'https://github.com/devopstrainingblr/maven-web-application-1.git'
24 |
25 | }
26 | }
27 |
28 | stage('Build'){
29 | steps{
30 | sh "mvn clean package"
31 | }
32 | }
33 | /*
34 | stage('ExecuteSonarQubeReport'){
35 | steps{
36 | sh "mvn clean sonar:sonar"
37 | }
38 | }
39 |
40 | stage('UploadArtifactsIntoNexus'){
41 | steps{
42 | sh "mvn clean deploy"
43 | }
44 | }
45 |
46 | stage('DeployAppIntoTomcat'){
47 | steps{
48 | sshagent(['bfe1b3c1-c29b-4a4d-b97a-c068b7748cd0']) {
49 | sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war ec2-user@35.154.190.162:/opt/apache-tomcat-9.0.50/webapps/"
50 | }
51 | }
52 | }
53 | */
54 | }//Stages Closing
55 |
56 | post{
57 |
58 | success{
59 | emailext to: 'devopstrainingblr@gmail.com,mithuntechnologies@yahoo.com',
60 | subject: "Pipeline Build is over .. Build # is ..${env.BUILD_NUMBER} and Build status is.. ${currentBuild.result}.",
61 | body: "Pipeline Build is over .. Build # is ..${env.BUILD_NUMBER} and Build status is.. ${currentBuild.result}.",
62 | replyTo: 'devopstrainingblr@gmail.com'
63 | }
64 |
65 | failure{
66 | emailext to: 'devopstrainingblr@gmail.com,mithuntechnologies@yahoo.com',
67 | subject: "Pipeline Build is over .. Build # is ..${env.BUILD_NUMBER} and Build status is.. ${currentBuild.result}.",
68 | body: "Pipeline Build is over .. Build # is ..${env.BUILD_NUMBER} and Build status is.. ${currentBuild.result}.",
69 | replyTo: 'devopstrainingblr@gmail.com'
70 | }
71 |
72 | }
73 |
74 |
75 | }//Pipeline closing
76 |
--------------------------------------------------------------------------------
/MavenWebApplication.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: Deployment
3 | metadata:
4 | name: webpage-deployment
5 | namespace: production
6 | spec:
7 | replicas: 2
8 | revisionHistoryLimit: 5
9 | selector:
10 | matchLabels:
11 | application: webpage
12 | strategy:
13 | type: RollingUpdate
14 | rollingUpdate:
15 | maxSurge: 1
16 | maxUnavailable: 1
17 | minReadySeconds: 30
18 | template:
19 | metadata:
20 | name: webpage-pod
21 | labels:
22 | application: webpage
23 | spec:
24 | containers:
25 | - name: webpage-container
26 | image: mithuntechnologies/maven-web-application:1
27 | imagePullPolicy: Always
28 | ports:
29 | - containerPort: 8080
30 | ---
31 | apiVersion: v1
32 | kind: Service
33 | metadata:
34 | name: webpage-service
35 | namespace: production
36 | spec:
37 | type: NodePort
38 | selector:
39 | application: webpage
40 | ports:
41 | - port: 80
42 | targetPort: 8080
--------------------------------------------------------------------------------
/appdeploy.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all
3 | become: true
4 | tasks:
5 | - name: stop tomcat
6 | systemd:
7 | name: tomcat.service
8 | state: stopped
9 | - name: delete old application package
10 | file:
11 | path: /usr/local/apache-tomcat-7.0.76/webapps/maven-web-application.war
12 | state: absent
13 | - name: copy application package
14 | copy:
15 | src: target/maven-web-application.war
16 | dest: /usr/local/apache-tomcat-7.0.76/webapps/maven-web-application.war
17 | owner: tomcat
18 | group: tomcat
19 | - name: start tomcat
20 | systemd:
21 | name: tomcat.service
22 | state: started
23 | daemon_reload: yes
24 | enabled: yes
25 | - name: Pause for 1 Minute and continue with play
26 | pause:
27 | minutes: 1
28 | - name: Confirm that 200 OK response is returned
29 | uri:
30 | url: "http://{{ ansible_host }}:8080/maven-web-application/"
31 | status_code: 200
32 | ...
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | springboot:
4 | image: dockerhandson/maven-web-application:VERSION
5 | restart: always
6 | ports:
7 | - 9090:8080
8 | networks:
9 | - mavenappbridge
10 | networks:
11 | mavenappbridge:
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
Service : Get Employee Details
52 |Mithun Technologies - Consultant, Training and Development Center.
55 |Copyrights 2025 by Mithun Technologies,Bengaluru
56 | 57 | 58 |