From 5d3db5de49fb1bf333c93636faa6a590c317f752 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 19 Feb 2023 09:06:22 +0530 Subject: [PATCH 01/13] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 78662a2a..296fa293 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ ``` mvn clean package -and build the instruction . ``` # Deploy instruction From aa131d686156de2bdedf5e6ad90f20515c2dc579 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 19 Feb 2023 09:11:00 +0530 Subject: [PATCH 02/13] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 296fa293..b5148c95 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,4 @@ mvn clean package Deploy ```target/WebApp.war``` on Tomcat properly for better experience. + From a7727a8daad489b92c402be9d6917f56b7502f24 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 19 Feb 2023 09:21:25 +0530 Subject: [PATCH 03/13] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b5148c95..9284772e 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,4 @@ mvn clean package Deploy ```target/WebApp.war``` on Tomcat properly for better experience. + From 5b484f91dc0d2a66d8e0b3c115fe09780c33c583 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 19 Feb 2023 09:24:00 +0530 Subject: [PATCH 04/13] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b43cb6e..8491d28a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ lu.amazon.aws.demo WebApp war - 2.0 + 2.0-SNAPSHOT WebApp Maven Webapp http://maven.apache.org From 31ed192b253a6fb246e1716221010536761c5729 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 09:52:40 +0530 Subject: [PATCH 05/13] build stage --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b77cce31..ace761ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline{ script{ sh """ printenv - cp -r ../sample-web-app-pull-request@2/target . + cp -r ../$JOB_BASE_NAME@2/target . docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag """ } From a397370410657cf0ab64582e5c10bd269c5b0603 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 09:58:36 +0530 Subject: [PATCH 06/13] build stage --- Jenkinsfile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ace761ea..c12173c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,7 @@ pipeline{ agent any environment{ Docker_tag = getDockerTag() + docker_pws = credentials('docker-password') } stages{ stage("Sonar scan"){ @@ -50,7 +51,6 @@ pipeline{ steps{ script{ sh """ - printenv cp -r ../$JOB_BASE_NAME@2/target . docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag """ @@ -58,6 +58,18 @@ pipeline{ } } + + stage('docker login & push'){ + steps{ + script{ + sh """ + docker login -u admin -p $docker_pws 34.125.26.221:8083 + docker push 34.125.26.221:8083/sample-app:$Docker_tag + """ + } + } + } + } // post { From 7db2ad7797bf43778201ce9a6acb1cdf9b2d1e13 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 10:04:59 +0530 Subject: [PATCH 07/13] build stage --- Jenkinsfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c12173c2..f1c723c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,15 +66,17 @@ pipeline{ docker login -u admin -p $docker_pws 34.125.26.221:8083 docker push 34.125.26.221:8083/sample-app:$Docker_tag """ + addBadge(icon: 'save.gif', text: 'docker repo', link: 'http://34.125.26.221:8081/#browse/browse:docker-hosted:v2%2Fsample-app') + currentBuild.description = "34.125.26.221:8083/sample-app:$Docker_tag" } } } } - // post { - // always{ - // cleanWs() - // } - // } + post { + always{ + cleanWs() + } + } } \ No newline at end of file From 03aabc5dc63bf6ce1419526f6ed97e9662067dc3 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 10:08:30 +0530 Subject: [PATCH 08/13] build stage --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f1c723c3..74b67db4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ pipeline{ docker push 34.125.26.221:8083/sample-app:$Docker_tag """ addBadge(icon: 'save.gif', text: 'docker repo', link: 'http://34.125.26.221:8081/#browse/browse:docker-hosted:v2%2Fsample-app') - currentBuild.description = "34.125.26.221:8083/sample-app:$Docker_tag" + currentBuild.description = "sample-app:$Docker_tag" } } } From b065c81be6f3edda78c7863092d6a6d8f0ca6b1d Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 11:00:26 +0530 Subject: [PATCH 09/13] k8s auth stage --- Jenkinsfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 74b67db4..f7a30132 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,6 +72,16 @@ pipeline{ } } + stage('authenticate and prepare k8s manifest files'){ + steps{ + script{ + configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { + sh 'kubectl get po' + } + } + } + } + } post { From 1832dfd1f1e2243a725371df8fedc6f88b138f12 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 11:32:53 +0530 Subject: [PATCH 10/13] k8s auth stage --- Jenkinsfile | 7 ++++++- deployment.yaml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f7a30132..8afa8223 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,12 @@ pipeline{ steps{ script{ configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - sh 'kubectl get po' + sh """ + kubectl get po + final_tag=$(echo $Docker_tag | tr -d ' ') + sed -i "s|TAG|$final_tag|" deployment.yaml + cat deployment.yaml + """ } } } diff --git a/deployment.yaml b/deployment.yaml index 08bfdcc7..bb466fc2 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - name: devops-training - image: deekshithsn/webapp:TAG + image: 34.125.26.221/sample-app:TAG command: ["/bin/sh"] args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"] ports: From f95976a83d7ab1a0c7455ed2f8cc3d26f2bfceae Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 11:34:01 +0530 Subject: [PATCH 11/13] k8s auth stage --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8afa8223..a671ae4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,12 +76,12 @@ pipeline{ steps{ script{ configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - sh """ + sh ''' kubectl get po final_tag=$(echo $Docker_tag | tr -d ' ') sed -i "s|TAG|$final_tag|" deployment.yaml cat deployment.yaml - """ + ''' } } } From 70a853b016ea13e69b2ae047c432a8627c809465 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 11:49:40 +0530 Subject: [PATCH 12/13] k8s auth stage --- Jenkinsfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index a671ae4d..76740241 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,6 +87,28 @@ pipeline{ } } + stage('approval stage'){ + steps{ + script{ + timeout(5){ + mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "deekshithsn@gmail.com"; + input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy') + } + } + } + } + + stage('deploy to k8s cluster'){ + steps{ + script{ + configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { + sh ''' + kubectl apply -f deployment.yaml + ''' + } + } + } + } } post { From 1f614eff58f6ee6ba4d29bd4638ba65a418d56f9 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 11:52:07 +0530 Subject: [PATCH 13/13] k8s auth stage --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 76740241..5fd0f03d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -92,7 +92,7 @@ pipeline{ script{ timeout(5){ mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "deekshithsn@gmail.com"; - input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy') + input( message: "Deploy ${params.project_name}?", ok: 'Deploy') } } }