From fec650e67aa745e7b5f6c0c4a06523ff5a438c4f Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 12 Feb 2023 10:50:23 +0530 Subject: [PATCH 01/28] Delete Jenkinsfile --- Jenkinsfile | 121 ---------------------------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index bac1d50b..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,121 +0,0 @@ - def getDockerTag(){ - def tag = sh script: 'git rev-parse --short HEAD', returnStdout: true - return tag - } - -pipeline{ - agent any - environment{ - Docker_tag = getDockerTag() - docker_login = credentials('public-docker-auth') - } - stages{ - stage("static code analysis"){ - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' - } - } - steps{ - script{ - withSonarQubeEnv(credentialsId: 'sonar-qube-token') { - sh "mvn sonar:sonar" - } - timeout(5){ - def qg = waitForQualityGate() - if (qg.status != 'OK'){ - error "code didnt met qulaity gate" - } - } - } - } - } - - stage('build'){ - agent { - docker { - image 'maven' - args '-v $HOME/.m2:/root/.m2' - } - } - steps{ - script{ - sh "mvn clean install" - } - } - } - - stage('docker build'){ - steps { - script{ - sh """ - pwd - ls -la - cp -r ../backend-app@2/target . - docker build . -t deekshithsn/webapp:$Docker_tag - """ - currentBuild.description = "deekshithsn/webapp:$Docker_tag" - } - } - } - - stage('docker upload'){ - steps{ - script{ - sh """ - docker login -u $docker_login_USR -p $docker_login_PSW - docker push deekshithsn/webapp:$Docker_tag - """ - addBadge(icon: 'info.gif', text: 'docker registry', link: 'https://hub.docker.com/repository/docker/deekshithsn/webapp/general') - } - } - } - - stage('approval from managers'){ - input { - message "do you want to procced for deployment?" - ok "Procced?" - submitter "alice,bob" - parameters { - string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') - } - } - steps{ - script{ - sh "echo Approved!!!!" - } - } - } - - stage('prepare deplyment file'){ - steps{ - script{ - sh ''' - final_tag=$(echo $Docker_tag | tr -d ' ') - sed -i "s|TAG|$final_tag|" deployment.yaml - cat deployment.yaml - ''' - } - } - } - - stage('authenticate & deploy'){ - steps{ - script{ - sh""" - export KUBECONFIG=/opt/config - kubectl get po - kubectl apply -f deployment.yaml - """ - } - } - } - } - - post{ - always{ - cleanWs() - } - } -} \ No newline at end of file From c62e33c0b96f4af977df8726cc1f77397010e022 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 12 Feb 2023 11:03:27 +0530 Subject: [PATCH 02/28] implementing jenkinsfile --- Jenkinsfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..43ed6eac --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,33 @@ +pipeline{ + agent any + stages{ + stage("Sonar scan"){ + agent { + docker { + image 'maven' + args '-v /root/.m2:/root/.m2' + } + } + steps{ + script{ + withSonarQubeEnv(credentialsId: 'sonar-token') { + sh 'printenv' + sh 'mvn sonar:sonar' + } + timeout(5){ + def qg = waitForQualityGate() + if (qg.status != 'OK'){ + error "code didnt met qulaity gate" + } + } + } + } + } + } + + post { + always{ + cleanWs() + } + } +} \ No newline at end of file From b0fe053ede3696524759946ff5056615ae2243e3 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sat, 18 Feb 2023 09:01:39 +0530 Subject: [PATCH 03/28] added build stage --- Jenkinsfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 43ed6eac..cace36f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,21 @@ pipeline{ } } } + + stage('build the application'){ + agent { + docker { + image 'maven' + args '-v /root/.m2:/root/.m2' + } + } + steps{ + script{ + sh "mvn clean install" + } + } + } + } post { From 1b383f1a373b34c455044d6001336edfdf1c0ed8 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 18 Feb 2023 09:49:15 +0530 Subject: [PATCH 04/28] Update pom.xml --- pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 81c6a03d..58918c49 100644 --- a/pom.xml +++ b/pom.xml @@ -30,4 +30,16 @@ - \ No newline at end of file + + + + nexusdeploymentrepo + http://34.125.26.221:8081/repository/maven-hosted-snapshot/ + + + nexusdeploymentrepo + http://34.125.26.221:8081/repository/maven-hosted-release/ + + + + From e66efbb77330cf6da5b1f16f31a42723c1e46c0e Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sat, 18 Feb 2023 09:54:05 +0530 Subject: [PATCH 05/28] mvn deploy --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cace36f8..4265b450 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,7 +33,7 @@ pipeline{ } steps{ script{ - sh "mvn clean install" + sh "mvn clean deploy" } } } From 8bee513377e5464cb76d663af56411c7c25879f4 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 18 Feb 2023 10:13:55 +0530 Subject: [PATCH 06/28] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58918c49..83ced56d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ lu.amazon.aws.demo WebApp war - 1.0-SNAPSHOT + 1.0 WebApp Maven Webapp http://maven.apache.org From 49bc14ff2f0d251853a00454dee32bfdcdcbcf21 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 18 Feb 2023 10:18:34 +0530 Subject: [PATCH 07/28] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 83ced56d..9b43cb6e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ lu.amazon.aws.demo WebApp war - 1.0 + 2.0 WebApp Maven Webapp http://maven.apache.org From 9b81f96f501921f542e6f11fb023c34429678a34 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 09:38:10 +0530 Subject: [PATCH 08/28] build stage --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 4265b450..d08a0e9d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,13 @@ +def getDockerTag(){ + def tag = sh script: 'git rev-parse --short HEAD', returnStdout: true + return tag + } + pipeline{ agent any + environment{ + Docker_tag = getDockerTag() + } stages{ stage("Sonar scan"){ agent { @@ -38,6 +46,14 @@ pipeline{ } } + stage('docker build'){ + steps{ + script{ + sh "docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag" + } + } + } + } post { From 747a289c1b0eb8f3f79cfe7225cd7bcb18bb5f30 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 09:40:21 +0530 Subject: [PATCH 09/28] build stage --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d08a0e9d..b54c068f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,9 +56,9 @@ pipeline{ } - post { - always{ - cleanWs() - } - } + // post { + // always{ + // cleanWs() + // } + // } } \ No newline at end of file From e6c3a2c9cf64acead6814543ac29cac77b768885 Mon Sep 17 00:00:00 2001 From: DeekshithSN Date: Sun, 19 Feb 2023 09:44:21 +0530 Subject: [PATCH 10/28] build stage --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b54c068f..b77cce31 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,7 +49,11 @@ pipeline{ stage('docker build'){ steps{ script{ - sh "docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag" + sh """ + printenv + cp -r ../sample-web-app-pull-request@2/target . + docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag + """ } } } From 5d3db5de49fb1bf333c93636faa6a590c317f752 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sun, 19 Feb 2023 09:06:22 +0530 Subject: [PATCH 11/28] 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 12/28] 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 13/28] 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 14/28] 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 15/28] 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 16/28] 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 17/28] 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 18/28] 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 19/28] 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 20/28] 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 21/28] 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 22/28] 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 23/28] 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') } } } From 6e0d38fb28c450ab2d61ff2bbe12a1ca9d18fae0 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 1 Jul 2023 12:06:29 +0530 Subject: [PATCH 24/28] Update Jenkinsfile --- Jenkinsfile | 110 +++++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 70 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5fd0f03d..1e2d2471 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,16 +19,8 @@ pipeline{ } steps{ script{ - withSonarQubeEnv(credentialsId: 'sonar-token') { - sh 'printenv' - sh 'mvn sonar:sonar' - } - timeout(5){ - def qg = waitForQualityGate() - if (qg.status != 'OK'){ - error "code didnt met qulaity gate" - } - } + sh "echo executing sonar scan" + sh "sleep 90" } } } @@ -42,73 +34,51 @@ pipeline{ } steps{ script{ - sh "mvn clean deploy" + sh "mvn clean install" } } } - stage('docker build'){ - steps{ - script{ - sh """ - cp -r ../$JOB_BASE_NAME@2/target . - docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag - """ - } - } - } + // stage('docker build'){ + // steps{ + // script{ + // sh """ + // cp -r ../$JOB_BASE_NAME@2/target . + // docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag + // """ + // } + // } + // } - 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 - """ - addBadge(icon: 'save.gif', text: 'docker repo', link: 'http://34.125.26.221:8081/#browse/browse:docker-hosted:v2%2Fsample-app') - currentBuild.description = "sample-app:$Docker_tag" - } - } - } - - stage('authenticate and prepare k8s manifest files'){ - steps{ - script{ - configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - sh ''' - kubectl get po - final_tag=$(echo $Docker_tag | tr -d ' ') - sed -i "s|TAG|$final_tag|" deployment.yaml - cat deployment.yaml - ''' - } - } - } - } + // 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 + // """ + // addBadge(icon: 'save.gif', text: 'docker repo', link: 'http://34.125.26.221:8081/#browse/browse:docker-hosted:v2%2Fsample-app') + // currentBuild.description = "sample-app:$Docker_tag" + // } + // } + // } - 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( message: "Deploy ${params.project_name}?", ok: 'Deploy') - } - } - } - } + // stage('deploy the application'){ + // steps{ + // script{ + // configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { + // sh ''' + // kubectl get po + // final_tag=$(echo $Docker_tag | tr -d ' ') + // sed -i "s|TAG|$final_tag|" deployment.yaml + // cat deployment.yaml + // ''' + // } + // } + // } + // } - stage('deploy to k8s cluster'){ - steps{ - script{ - configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - sh ''' - kubectl apply -f deployment.yaml - ''' - } - } - } - } } post { @@ -116,4 +86,4 @@ pipeline{ cleanWs() } } -} \ No newline at end of file +} From 00f5c983ccaa9226c81076cfe7f8489a006ee0f6 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 1 Jul 2023 12:12:12 +0530 Subject: [PATCH 25/28] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1e2d2471..7895690c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline{ agent any environment{ Docker_tag = getDockerTag() - docker_pws = credentials('docker-password') + docker_pws = credentials('docker-hub-password') } stages{ stage("Sonar scan"){ From 42dedc3d9ca4cf2d0038066af4d842662fa7b88a Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 1 Jul 2023 12:13:16 +0530 Subject: [PATCH 26/28] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7895690c..5b3b19f9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline{ steps{ script{ sh "echo executing sonar scan" - sh "sleep 90" + // sh "sleep 90" } } } From ebfa6de4c48ea7837f73b2db4166bbc88dcf3899 Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 1 Jul 2023 12:23:52 +0530 Subject: [PATCH 27/28] Update Jenkinsfile --- Jenkinsfile | 71 ++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5b3b19f9..cae8aea4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,45 +39,44 @@ pipeline{ } } - // stage('docker build'){ - // steps{ - // script{ - // sh """ - // cp -r ../$JOB_BASE_NAME@2/target . - // docker build . -t 34.125.26.221:8083/sample-app:$Docker_tag - // """ - // } - // } - // } + stage('docker build'){ + steps{ + script{ + sh """ + docker build . -t deekshithsn/java-app-hbc:$Docker_tag + """ + } + } + } - // 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 - // """ - // addBadge(icon: 'save.gif', text: 'docker repo', link: 'http://34.125.26.221:8081/#browse/browse:docker-hosted:v2%2Fsample-app') - // currentBuild.description = "sample-app:$Docker_tag" - // } - // } - // } + stage('docker login & push'){ + steps{ + script{ + sh """ + docker login -u deekshithsn -p $docker_pws + docker push deekshithsn/java-app-hbc:$Docker_tag + """ + addBadge(icon: 'save.gif', text: 'docker repo', link: 'https://hub.docker.com/repository/docker/deekshithsn/java-app-hbc') + currentBuild.description = "deekshithsn/java-app-hbc:$Docker_tag" + } + } + } - // stage('deploy the application'){ - // steps{ - // script{ - // configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - // sh ''' - // kubectl get po - // final_tag=$(echo $Docker_tag | tr -d ' ') - // sed -i "s|TAG|$final_tag|" deployment.yaml - // cat deployment.yaml - // ''' - // } - // } - // } - // } + stage('deploy the application'){ + steps{ + script{ + configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { + sh ''' + kubectl get po + final_tag=$(echo $Docker_tag | tr -d ' ') + sed -i "s|TAG|$final_tag|" deployment.yaml + cat deployment.yaml + ''' + } + } + } + } } From 1704c79fc824a419f2341a9f47ae348295ddcb8e Mon Sep 17 00:00:00 2001 From: Deekshith SN Date: Sat, 1 Jul 2023 16:53:34 +0530 Subject: [PATCH 28/28] Update Jenkinsfile --- Jenkinsfile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cae8aea4..45561c81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,14 +66,10 @@ pipeline{ stage('deploy the application'){ steps{ script{ - configFileProvider([configFile(fileId: 'kube-dev-config', variable: 'KUBECONFIG')]) { - sh ''' - kubectl get po - final_tag=$(echo $Docker_tag | tr -d ' ') - sed -i "s|TAG|$final_tag|" deployment.yaml - cat deployment.yaml - ''' - } + sh """ + docker rm $( docker stop $( docker ps -aq)) + docker run -d -p 9000:8080 deekshithsn/java-app-hbc:$Docker_tag + """ } } }