From df0bd66047e7f868021e55a063f7eb9a3b8f0a43 Mon Sep 17 00:00:00 2001 From: mohandevops1869 Date: Mon, 26 Feb 2024 12:22:31 +0530 Subject: [PATCH 1/3] add-git-ignorefile --- .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e69de29b From 9d86f0a58a9e924915c193ce0ac6d195e8464fb8 Mon Sep 17 00:00:00 2001 From: mohandevops1869 Date: Mon, 26 Feb 2024 12:26:01 +0530 Subject: [PATCH 2/3] asome-file-added --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e69de29b..244652b4 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +ansible.yaml +deployment.yaml From b259520a8124071dc5babaa084e4d084ddadd42e Mon Sep 17 00:00:00 2001 From: mohandevops1869 Date: Mon, 26 Feb 2024 15:04:55 +0530 Subject: [PATCH 3/3] updated --- 123.txt | 0 Dockerfile | 10 +- Jenkinsfile | 158 +++++++++++------------ README.md | 28 ++-- ansible.yaml | 22 ++-- deployment.yaml | 76 +++++------ hosts | 4 +- pom.xml | 42 +++--- src/main/webapp/WEB-INF/web.xml | 14 +- src/main/webapp/css/jumbotron.css | 8 +- src/main/webapp/index.jsp | 208 +++++++++++++++--------------- test | 6 +- 12 files changed, 288 insertions(+), 288 deletions(-) create mode 100644 123.txt diff --git a/123.txt b/123.txt new file mode 100644 index 00000000..e69de29b diff --git a/Dockerfile b/Dockerfile index ceb6b0ab..cfe189d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM tomcat -WORKDIR webapps -COPY target/WebApp.war . -RUN rm -rf ROOT && mv WebApp.war ROOT.war -ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"] +FROM tomcat +WORKDIR webapps +COPY target/WebApp.war . +RUN rm -rf ROOT && mv WebApp.war ROOT.war +ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"] diff --git a/Jenkinsfile b/Jenkinsfile index b6c34792..805dcbe1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,79 +1,79 @@ -currentBuild.displayName = "Final_Demo # "+currentBuild.number - - def getDockerTag(){ - def tag = sh script: 'git rev-parse HEAD', returnStdout: true - return tag - } - - -pipeline{ - agent any - environment{ - Docker_tag = getDockerTag() - } - - stages{ - - - stage('Quality Gate Statuc Check'){ - - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' - } - } - steps{ - script{ - withSonarQubeEnv('sonarserver') { - sh "mvn sonar:sonar" - } - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } - } - sh "mvn clean install" - } - } - } - - - - stage('build') - { - steps{ - script{ - sh 'cp -r ../devops-training@2/target .' - sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' - withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { - - sh 'docker login -u deekshithsn -p $docker_password' - sh 'docker push deekshithsn/devops-training:$Docker_tag' - } - } - } - } - - stage('ansible playbook'){ - steps{ - script{ - sh '''final_tag=$(echo $Docker_tag | tr -d ' ') - echo ${final_tag}test - sed -i "s/docker_tag/$final_tag/g" deployment.yaml - ''' - ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' - } - } - } - - - - } - - - - - -} +currentBuild.displayName = "Final_Demo # "+currentBuild.number + + def getDockerTag(){ + def tag = sh script: 'git rev-parse HEAD', returnStdout: true + return tag + } + + +pipeline{ + agent any + environment{ + Docker_tag = getDockerTag() + } + + stages{ + + + stage('Quality Gate Statuc Check'){ + + agent { + docker { + image 'maven' + args '-v $HOME/.m2:/root/.m2' + } + } + steps{ + script{ + withSonarQubeEnv('sonarserver') { + sh "mvn sonar:sonar" + } + timeout(time: 1, unit: 'HOURS') { + def qg = waitForQualityGate() + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } + } + sh "mvn clean install" + } + } + } + + + + stage('build') + { + steps{ + script{ + sh 'cp -r ../devops-training@2/target .' + sh 'docker build . -t deekshithsn/devops-training:$Docker_tag' + withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) { + + sh 'docker login -u deekshithsn -p $docker_password' + sh 'docker push deekshithsn/devops-training:$Docker_tag' + } + } + } + } + + stage('ansible playbook'){ + steps{ + script{ + sh '''final_tag=$(echo $Docker_tag | tr -d ' ') + echo ${final_tag}test + sed -i "s/docker_tag/$final_tag/g" deployment.yaml + ''' + ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml' + } + } + } + + + + } + + + + + +} diff --git a/README.md b/README.md index 78662a2a..cbe0ce89 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ - - -# Build Instruction - - -``` -mvn clean package -and build the instruction . -``` - -# Deploy instruction - -Deploy ```target/WebApp.war``` on Tomcat properly for better experience. - + + +# Build Instruction + + +``` +mvn clean package +and build the instruction . +``` + +# Deploy instruction + +Deploy ```target/WebApp.war``` on Tomcat properly for better experience. + diff --git a/ansible.yaml b/ansible.yaml index a349d7b8..68f5bd8e 100644 --- a/ansible.yaml +++ b/ansible.yaml @@ -1,11 +1,11 @@ -- hosts: test - tasks: - - name: copy deployment file to kubernetes master - copy: - src: deployment.yaml - dest: /root/ - - name: delete the previous of kubernetes objects - command: kubectl delete -f /root/deployment.yaml - - name: Create a Deployment by reading the definition from a local file - command: kubectl apply -f /root/deployment.yaml - +- hosts: test + tasks: + - name: copy deployment file to kubernetes master + copy: + src: deployment.yaml + dest: /root/ + - name: delete the previous of kubernetes objects + command: kubectl delete -f /root/deployment.yaml + - name: Create a Deployment by reading the definition from a local file + command: kubectl apply -f /root/deployment.yaml + diff --git a/deployment.yaml b/deployment.yaml index 55d9da8b..e6d8d3b9 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -1,38 +1,38 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: devops-training -spec: - selector: - matchLabels: - app: devops-training - template: - metadata: - labels: - app: devops-training - spec: - containers: - - name: devops-training - image: deekshithsn/devops-training:docker_tag - command: ["/bin/sh"] - args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] - ports: - - name: http - containerPort: 8080 - replicas: 2 ---- -apiVersion: v1 -kind: Service -metadata: - name: devops-training-app-service - labels: - app: devops-training -spec: - type: NodePort - ports: - - port: 8080 - nodePort: 31884 - protocol: TCP - name: http - selector: - app: devops-training +apiVersion: apps/v1 +kind: Deployment +metadata: + name: devops-training +spec: + selector: + matchLabels: + app: devops-training + template: + metadata: + labels: + app: devops-training + spec: + containers: + - name: devops-training + image: deekshithsn/devops-training:docker_tag + command: ["/bin/sh"] + args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] + ports: + - name: http + containerPort: 8080 + replicas: 2 +--- +apiVersion: v1 +kind: Service +metadata: + name: devops-training-app-service + labels: + app: devops-training +spec: + type: NodePort + ports: + - port: 8080 + nodePort: 31884 + protocol: TCP + name: http + selector: + app: devops-training diff --git a/hosts b/hosts index 289312cd..4ce5cf1a 100644 --- a/hosts +++ b/hosts @@ -1,2 +1,2 @@ -[test] -Host_ip +[test] +Host_ip diff --git a/pom.xml b/pom.xml index 3909d5ff..477aa94e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,21 +1,21 @@ - - 4.0.0 - lu.amazon.aws.demo - WebApp - war - 1.0-SNAPSHOT - WebApp Maven Webapp - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - - WebApp - - + + 4.0.0 + lu.amazon.aws.demo + WebApp + war + 1.0-SNAPSHOT + WebApp Maven Webapp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + + WebApp + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 9f88c1f9..04563ea8 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,7 @@ - - - - Archetype Created Web Application - + + + + Archetype Created Web Application + diff --git a/src/main/webapp/css/jumbotron.css b/src/main/webapp/css/jumbotron.css index 54ae24b1..90f8debb 100644 --- a/src/main/webapp/css/jumbotron.css +++ b/src/main/webapp/css/jumbotron.css @@ -1,5 +1,5 @@ -/* Move down content because we have a fixed navbar that is 50px tall */ -body { - padding-top: 50px; - padding-bottom: 20px; +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px; + padding-bottom: 20px; } \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 9fda98e7..45399646 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,104 +1,104 @@ - - - - - - - - - - - Jumbotron Template for Bootstrap - - - - - - - - - - - - - -
-
-

Hello

-

This is from Dev Environment

-

Learn more »

-
-
- -
- -
-
-

Devops

-

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.

-

View details »

-
-
-
-
-

Jenkins

-

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

-

View details »

-
-
-

Maven

-

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.

-

View details »

-
- -
- -
- -
-

© Company 2014

-
-
- - - - - - - - - - - - + + + + + + + + + + + Jumbotron Template for Bootstrap + + + + + + + + + + + + + +
+
+

Hello

+

This is from Dev Environment

+

Learn more »

+
+
+ +
+ +
+
+

Devops

+

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.

+

View details »

+
+
+
+
+

Jenkins

+

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

+

View details »

+
+
+

Maven

+

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.

+

View details »

+
+ +
+ +
+ +
+

© Company 2014

+
+
+ + + + + + + + + + + + diff --git a/test b/test index 03e0cd9a..62bf9e84 100644 --- a/test +++ b/test @@ -1,3 +1,3 @@ -My changes -A B -githubtrigger +My changes +A B +githubtrigger