From deb9b84f882c30af1168b2be81a22bbcb2d7ce58 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:06:41 +0530 Subject: [PATCH 01/25] Update Jenkinsfile --- Jenkinsfile | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34cca21b2b2..2bd546d80cb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,34 @@ -pipeline{ - agent any - triggers { - pollSCM '* * * * *' +node{ + stage('Git Checkout'){ + git credentialsId: 'git-hub', url: 'https://github.com/javahometech/my-app' + } + stage('MVN Package'){ + def mvnHome = tool name: 'maven-3', type: 'maven' + sh "${mvnHome}/bin/mvn clean package" + } + stage('Build Docker Image'){ + sh 'docker build -t sarath818/my-app:0.0.1 .' + } + stage('Upload Image to DockerHub'){ + withCredentials([string(credentialsId: 'docker-hub', variable: 'password')]) { + sh "docker login -u sarath818 -p ${password}" } - stages{ - stage("SCM"){ - steps{ - echo "job ran.....again and again" - } - } + sh 'docker push sarath818/my-app:0.0.1' + } + stage('Remove Old Containers'){ + sshagent(['dev-docker']) { + try{ + sh 'ssh -o StrictHostKeyChecking=no ec2-user@172.31.90.229 docker rm -f my-app' + + }catch(error){ + + } } -} + } + stage('Deploy-Dev'){ + sshagent(['dev-docker']) { + sh 'ssh -o StrictHostKeyChecking=no ec2-user@172.31.90.229' + sh 'docker run -d -p 8080:8080 --name my-app sarath818/my-app:0.0.1' + } + } + } From 972968936f6788f8c4d76294eefedafdbe3a9f17 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:13:26 +0530 Subject: [PATCH 02/25] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 50ef85808bf..02ae8d00ceb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM tomcat:8 +LABEL Sre=sreenu LABEL app=my-app COPY target/*.war /usr/local/tomcat/webapps/myweb.war # testing webhook From 7dff366d2aa904e8671e41a3f935c4004ea576f5 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:17:54 +0530 Subject: [PATCH 03/25] Update Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 02ae8d00ceb..50ef85808bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM tomcat:8 -LABEL Sre=sreenu LABEL app=my-app COPY target/*.war /usr/local/tomcat/webapps/myweb.war # testing webhook From 147a76a9ee436affe2a7cf0b9cac00703f362964 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:21:49 +0530 Subject: [PATCH 04/25] Update Jenkinsfile_old --- Jenkinsfile_old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_old b/Jenkinsfile_old index ba0c84bbc1a..124a6e03738 100644 --- a/Jenkinsfile_old +++ b/Jenkinsfile_old @@ -1,4 +1,4 @@ -@Library('javahome-libs') _ + pipeline{ agent any From 2dfc15a778c5a31fe022fbd4103d07edd1520e33 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:25:23 +0530 Subject: [PATCH 05/25] Update Jenkinsfile_old --- Jenkinsfile_old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_old b/Jenkinsfile_old index 124a6e03738..494fd6cdce0 100644 --- a/Jenkinsfile_old +++ b/Jenkinsfile_old @@ -1,4 +1,4 @@ - +//this is for demo file pipeline{ agent any From 0a0c335bdf521a148cda93e097221450be17bc51 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:28:28 +0530 Subject: [PATCH 06/25] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 2bd546d80cb..aed7eaeee39 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,4 @@ +// this is for checking// node{ stage('Git Checkout'){ git credentialsId: 'git-hub', url: 'https://github.com/javahometech/my-app' From 1f856f5788897aadc012af4f30ab07aa5ebee16c Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:32:13 +0530 Subject: [PATCH 07/25] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index aed7eaeee39..78cbbef8703 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -// this is for checking// + node{ stage('Git Checkout'){ git credentialsId: 'git-hub', url: 'https://github.com/javahometech/my-app' From eb9ffad67741f05dcf18049ab9afa41df7304189 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:52:47 +0530 Subject: [PATCH 08/25] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 78cbbef8703..f39a9bef3c8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ - +//welcome// node{ stage('Git Checkout'){ git credentialsId: 'git-hub', url: 'https://github.com/javahometech/my-app' From 05b6b50c9d5f13ee6df3a5a17393bdb3a4fe3637 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:54:55 +0530 Subject: [PATCH 09/25] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50ef85808bf..8702115a9e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ FROM tomcat:8 LABEL app=my-app COPY target/*.war /usr/local/tomcat/webapps/myweb.war -# testing webhook +# testing webhook# From fe4ec0cd5eb136661f287ddcce2883b7dc17aaef Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:56:56 +0530 Subject: [PATCH 10/25] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8702115a9e1..4023d8333b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ FROM tomcat:8 LABEL app=my-app COPY target/*.war /usr/local/tomcat/webapps/myweb.war -# testing webhook# + From f1b77ec1888c143dc460d0085ea68fcfff66d423 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:58:59 +0530 Subject: [PATCH 11/25] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 4023d8333b0..3348e18abb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM tomcat:8 LABEL app=my-app COPY target/*.war /usr/local/tomcat/webapps/myweb.war +#checking From 908623f5d7a52568ecf6d81e5f723454d358da63 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:00:07 +0530 Subject: [PATCH 12/25] Create jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 jenkins-declarative-pipeline diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline new file mode 100644 index 00000000000..5fd59531ff4 --- /dev/null +++ b/jenkins-declarative-pipeline @@ -0,0 +1,13 @@ +pipeline { + agent any + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'github', url: 'https://github.com/javahometech/myweb' + } + + } + } + } + + From 209bca3b2046940c6149fc7c7f9a7833abfa9194 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:15:54 +0530 Subject: [PATCH 13/25] Update jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline index 5fd59531ff4..23aeed4c3ab 100644 --- a/jenkins-declarative-pipeline +++ b/jenkins-declarative-pipeline @@ -6,8 +6,19 @@ pipeline { git credentialsId: 'github', url: 'https://github.com/javahometech/myweb' } + } + stage("Docker-Build"){ + steps{ + sh 'docker build -t sarath818/node-app:v10 .' + withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerhubpwd')]) { + sh "docker login -u sarath818 -p ${dockerhubpwd}" + sh 'docker push sarath818/node-app:v10' + } + } + } } + } From c82634474c97f71c555f8b309278d036b2f3518d Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:21:10 +0530 Subject: [PATCH 14/25] Update Dockerfile --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3348e18abb5..a426a20e3f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM tomcat:8 -LABEL app=my-app -COPY target/*.war /usr/local/tomcat/webapps/myweb.war -#checking +FROM tomcat:8.0.20-jre8 +# Dummy text to test +COPY target/myweb*.war /usr/local/tomcat/webapps/myweb.war +# Git webhook trigger demo +# TO test github push trigger hari From 0ec2831181ef7b1139a6405db5d05fab1ea488a8 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:29:23 +0530 Subject: [PATCH 15/25] Update jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline index 23aeed4c3ab..880bc27f948 100644 --- a/jenkins-declarative-pipeline +++ b/jenkins-declarative-pipeline @@ -3,7 +3,7 @@ pipeline { stages{ stage("Git Checkout"){ steps{ - git credentialsId: 'github', url: 'https://github.com/javahometech/myweb' + git credentialsId: 'github', url: 'https://github.com/javahometech/my-app' } } From 9e03e53439f5743bd76349f6dc54f485af888030 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:30:15 +0530 Subject: [PATCH 16/25] Update jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline index 880bc27f948..1e0bb9f5914 100644 --- a/jenkins-declarative-pipeline +++ b/jenkins-declarative-pipeline @@ -9,7 +9,7 @@ pipeline { } stage("Docker-Build"){ steps{ - sh 'docker build -t sarath818/node-app:v10 .' + sh 'docker build -t . sarath818/node-app:v10' withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerhubpwd')]) { sh "docker login -u sarath818 -p ${dockerhubpwd}" sh 'docker push sarath818/node-app:v10' From 916bdf86c6284cbd4b5a2b2a4f7cec2bb3cb3066 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:31:56 +0530 Subject: [PATCH 17/25] Update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a426a20e3f0..854bb3c6282 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM tomcat:8.0.20-jre8 # Dummy text to test -COPY target/myweb*.war /usr/local/tomcat/webapps/myweb.war - +# COPY target/myweb*.war /usr/local/tomcat/webapps/myweb.war +RUN mkdir srilatha # Git webhook trigger demo # TO test github push trigger hari From 248b18ea42e33f6dc38fa6c35e99b6e569106612 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 17:34:04 +0530 Subject: [PATCH 18/25] Update jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline index 1e0bb9f5914..c2ae004f5ed 100644 --- a/jenkins-declarative-pipeline +++ b/jenkins-declarative-pipeline @@ -3,7 +3,7 @@ pipeline { stages{ stage("Git Checkout"){ steps{ - git credentialsId: 'github', url: 'https://github.com/javahometech/my-app' + git credentialsId: 'github', url: 'https://github.com/Sarath818/my-app' } } From b47bf99ff6c611110db3d88a557d6859a1f3495b Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:06:56 +0530 Subject: [PATCH 19/25] Update jenkins-declarative-pipeline --- jenkins-declarative-pipeline | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkins-declarative-pipeline b/jenkins-declarative-pipeline index c2ae004f5ed..306f94d3580 100644 --- a/jenkins-declarative-pipeline +++ b/jenkins-declarative-pipeline @@ -12,6 +12,7 @@ pipeline { sh 'docker build -t . sarath818/node-app:v10' withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerhubpwd')]) { sh "docker login -u sarath818 -p ${dockerhubpwd}" + } sh 'docker push sarath818/node-app:v10' } From ffe4c82fc70cd286e87a796fa582e53ef00596d6 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Fri, 18 Feb 2022 18:56:09 +0530 Subject: [PATCH 20/25] Create multi-agent-demo --- multi-agent-demo | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 multi-agent-demo diff --git a/multi-agent-demo b/multi-agent-demo new file mode 100644 index 00000000000..27e761751b2 --- /dev/null +++ b/multi-agent-demo @@ -0,0 +1,30 @@ +pipeline{ + agent any + tools { + maven 'maven-3' +} + stages{ + stage('Git Checkout'){ + agent{ + label 'master' + } + steps{ + git url: 'https://github.com/javahometech/my-app' + stash 'sourse' + } + } + stage('mvn package'){ + agent{ + label 'slave-one' + } + steps{ + script{ + unstash 'source' + + + sh "${mvnHome}/bin/mvn clean package" + } + } + } + } + } From f349c2ce794d2fefff6b337be16a99d0c1f2e58b Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:17:54 +0530 Subject: [PATCH 21/25] Update multi-agent-demo --- multi-agent-demo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/multi-agent-demo b/multi-agent-demo index 27e761751b2..60c24cb59af 100644 --- a/multi-agent-demo +++ b/multi-agent-demo @@ -9,8 +9,8 @@ pipeline{ label 'master' } steps{ - git url: 'https://github.com/javahometech/my-app' - stash 'sourse' + git url: 'https://github.com/sarath818/my-app' + stash 'source' } } stage('mvn package'){ @@ -22,7 +22,7 @@ pipeline{ unstash 'source' - sh "${mvnHome}/bin/mvn clean package" + sh "mvn clean package" } } } From e0ef66fa85affec5b76dc0a4a0d513a0d4f0d68c Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:18:42 +0530 Subject: [PATCH 22/25] Update multi-agent-demo --- multi-agent-demo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi-agent-demo b/multi-agent-demo index 60c24cb59af..fe5e2734bd5 100644 --- a/multi-agent-demo +++ b/multi-agent-demo @@ -27,4 +27,4 @@ pipeline{ } } } - } + ] From 3b3b2bbfcb8d8909166c1b4bba409f957f6f1c01 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:33:28 +0530 Subject: [PATCH 23/25] Update multi-agent-demo --- multi-agent-demo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multi-agent-demo b/multi-agent-demo index fe5e2734bd5..22bb4e3c4a3 100644 --- a/multi-agent-demo +++ b/multi-agent-demo @@ -18,11 +18,11 @@ pipeline{ label 'slave-one' } steps{ - script{ - unstash 'source' - + + unstash 'source' + sh "mvn clean package" - sh "mvn clean package" + } } } From 3f4fc5030657454d0c0d0b3f9f8cd7064533a8b1 Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Sun, 20 Feb 2022 14:35:47 +0530 Subject: [PATCH 24/25] Delete Jenkinsfile --- Jenkinsfile | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index f39a9bef3c8..00000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,35 +0,0 @@ -//welcome// -node{ - stage('Git Checkout'){ - git credentialsId: 'git-hub', url: 'https://github.com/javahometech/my-app' - } - stage('MVN Package'){ - def mvnHome = tool name: 'maven-3', type: 'maven' - sh "${mvnHome}/bin/mvn clean package" - } - stage('Build Docker Image'){ - sh 'docker build -t sarath818/my-app:0.0.1 .' - } - stage('Upload Image to DockerHub'){ - withCredentials([string(credentialsId: 'docker-hub', variable: 'password')]) { - sh "docker login -u sarath818 -p ${password}" - } - sh 'docker push sarath818/my-app:0.0.1' - } - stage('Remove Old Containers'){ - sshagent(['dev-docker']) { - try{ - sh 'ssh -o StrictHostKeyChecking=no ec2-user@172.31.90.229 docker rm -f my-app' - - }catch(error){ - - } - } - } - stage('Deploy-Dev'){ - sshagent(['dev-docker']) { - sh 'ssh -o StrictHostKeyChecking=no ec2-user@172.31.90.229' - sh 'docker run -d -p 8080:8080 --name my-app sarath818/my-app:0.0.1' - } - } - } From e55640f19efe3733c9b2dee59c504fcad9071c3e Mon Sep 17 00:00:00 2001 From: Sarath818 <96781349+Sarath818@users.noreply.github.com> Date: Sun, 20 Feb 2022 14:38:10 +0530 Subject: [PATCH 25/25] Delete Jenkinsfile_old --- Jenkinsfile_old | 62 ------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Jenkinsfile_old diff --git a/Jenkinsfile_old b/Jenkinsfile_old deleted file mode 100644 index 494fd6cdce0..00000000000 --- a/Jenkinsfile_old +++ /dev/null @@ -1,62 +0,0 @@ -//this is for demo file - -pipeline{ - agent any - options { - timeout(30) - } - stages{ - - stage('Maven and Sonar'){ - - parallel{ - stage('Sonar Analysis'){ - steps{ - withSonarQubeEnv('sonar7') { - sh 'mvn sonar:sonar' - } - - timeout(time: 1, unit: 'HOURS') { - script{ - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } - } - } - } - } - - stage('Mvn Build'){ - steps{ - sh 'mvn clean package' - } - } - - - } - - } - stage("Nexus Deploy"){ - steps{ - script{ - def pomFile = readMavenPom file: 'pom.xml' - nexusArtifactUploader artifacts: [[artifactId: 'myweb', classifier: '', file: "target/myweb-${pomFile.version}.war", type: 'war']], - credentialsId: 'nexus3', - groupId: 'in.javahome', - nexusUrl: '172.31.71.247:8081', - nexusVersion: 'nexus3', - protocol: 'http', repository: 'javahome-my-app', - version: pomFile.version - } - } - } - - stage('Tomcat Deploy'){ - steps{ - tomcatDeploy("172.31.35.55","ec2-user","myweb") - } - } - - } -}