├── Dockerfile ├── Jenkinsfile ├── README.md ├── ansible.yaml ├── deployment.yaml ├── hosts ├── pom.xml ├── src └── main │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── css │ └── jumbotron.css │ └── index.jsp └── test /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat 2 | WORKDIR webapps 3 | COPY target/WebApp.war . 4 | RUN rm -rf ROOT && mv WebApp.war ROOT.war 5 | ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"] 6 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | currentBuild.displayName = "Final_Demo # "+currentBuild.number 2 | 3 | def getDockerTag(){ 4 | def tag = sh script: 'git rev-parse HEAD', returnStdout: true 5 | return tag 6 | } 7 | 8 | 9 | pipeline{ 10 | agent any 11 | environment{ 12 | Docker_tag = getDockerTag() 13 | } 14 | 15 | stages{ 16 | 17 | 18 | stage('Quality Gate Statuc Check'){ 19 | 20 | agent { 21 | docker { 22 | image 'maven' 23 | args '-v $HOME/.m2:/root/.m2' 24 | } 25 | } 26 | steps{ 27 | script{ 28 | withSonarQubeEnv('sonarserver') { 29 | sh "mvn sonar:sonar" 30 | } 31 | timeout(time: 1, unit: 'HOURS') { 32 | def qg = waitForQualityGate() 33 | if (qg.status != 'OK') { 34 | error "Pipeline aborted due to quality gate failure: ${qg.status}" 35 | } 36 | } 37 | sh "mvn clean install" 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | stage('build') 45 | { 46 | steps{ 47 | script{ 48 | sh 'cp -r ../devops-training@2/target .' 49 | sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' 50 | withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { 51 | 52 | sh 'docker login -u deekshithsn -p $docker_password' 53 | sh 'docker push deekshithsn/devops-training:$Docker_tag' 54 | } 55 | } 56 | } 57 | } 58 | 59 | stage('ansible playbook'){ 60 | steps{ 61 | script{ 62 | sh '''final_tag=$(echo $Docker_tag | tr -d ' ') 63 | echo ${final_tag}test 64 | sed -i "s/docker_tag/$final_tag/g" deployment.yaml 65 | ''' 66 | ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' 67 | } 68 | } 69 | } 70 | 71 | 72 | 73 | } 74 | 75 | 76 | 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Build Instruction 4 | 5 | 6 | ``` 7 | mvn clean package 8 | and build the instruction . 9 | ``` 10 | 11 | # Deploy instruction 12 | 13 | Deploy ```target/WebApp.war``` on Tomcat properly for better experience. 14 | 15 | -------------------------------------------------------------------------------- /ansible.yaml: -------------------------------------------------------------------------------- 1 | - hosts: test 2 | tasks: 3 | - name: copy deployment file to kubernetes master 4 | copy: 5 | src: deployment.yaml 6 | dest: /root/ 7 | - name: delete the previous of kubernetes objects 8 | command: kubectl delete -f /root/deployment.yaml 9 | - name: Create a Deployment by reading the definition from a local file 10 | command: kubectl apply -f /root/deployment.yaml 11 | 12 | -------------------------------------------------------------------------------- /deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: devops-training 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: devops-training 9 | template: 10 | metadata: 11 | labels: 12 | app: devops-training 13 | spec: 14 | containers: 15 | - name: devops-training 16 | image: deekshithsn/devops-training:docker_tag 17 | command: ["/bin/sh"] 18 | args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] 19 | ports: 20 | - name: http 21 | containerPort: 8080 22 | replicas: 2 23 | --- 24 | apiVersion: v1 25 | kind: Service 26 | metadata: 27 | name: devops-training-app-service 28 | labels: 29 | app: devops-training 30 | spec: 31 | type: NodePort 32 | ports: 33 | - port: 8080 34 | nodePort: 31884 35 | protocol: TCP 36 | name: http 37 | selector: 38 | app: devops-training 39 | -------------------------------------------------------------------------------- /hosts: -------------------------------------------------------------------------------- 1 | [test] 2 | Host_ip 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | lu.amazon.aws.demo 5 | WebApp 6 | war 7 | 1.0-SNAPSHOT 8 | WebApp Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | 19 | WebApp 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/css/jumbotron.css: -------------------------------------------------------------------------------- 1 | /* Move down content because we have a fixed navbar that is 50px tall */ 2 | body { 3 | padding-top: 50px; 4 | padding-bottom: 20px; 5 | } -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Jumbotron Template for Bootstrap 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 49 | 50 | 51 |
52 |
53 |

Hello

54 |

This is from Dev Environment

55 |

Learn more »

56 |
57 |
58 | 59 |
60 | 61 |
62 |
63 |

Devops

64 |

DevOps is the combination of cultural philosophies, practices, and tools that increases an organization's ability to deliver applications and services at high velocity: evolving and improving products at a faster pace than organizations using traditional software development and infrastructure management processes.

65 |

View details »

66 |
67 |
68 |
69 |
70 |

Jenkins

71 |

Jenkins is a free and open source automation server. Jenkins helps to automate the non-human part of the software development process, with continuous integration and facilitating technical aspects of continuous delivery

72 |

View details »

73 |
74 |
75 |

Maven

76 |

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages.

77 |

View details »

78 |
79 | 84 |
85 | 86 |
87 | 88 | 91 |
92 | 93 | 94 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /test: -------------------------------------------------------------------------------- 1 | My changes 2 | A B 3 | githubtrigger 4 | --------------------------------------------------------------------------------