From f6bd445347ed9666561ad1ab039f4f26d5626dd0 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 11 Aug 2022 07:35:19 +0530 Subject: [PATCH 01/55] Update pom.xml --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 55ff3b2..01e0463 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,13 @@ 1.8 + sonarqube { + properties { + property "sonar.host.url", http://20.193.128.173:9000 // + property "sonar.projectName", "sample" + property "sonar.projectKey", "sample" + property "sonar.groovy.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec" } + } From ec087b03bcf5274f1021bc9665d8b61a5974fef7 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 11 Aug 2022 08:08:10 +0530 Subject: [PATCH 02/55] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 01e0463..7bbbcdb 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ property "sonar.host.url", http://20.193.128.173:9000 // property "sonar.projectName", "sample" property "sonar.projectKey", "sample" - property "sonar.groovy.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec" } + } } From 362e5e0463066a245d6793ac1ef2cbdd1c507bb9 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 11 Aug 2022 08:09:49 +0530 Subject: [PATCH 03/55] Update pom.xml --- pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pom.xml b/pom.xml index 7bbbcdb..55ff3b2 100644 --- a/pom.xml +++ b/pom.xml @@ -16,13 +16,6 @@ 1.8 - sonarqube { - properties { - property "sonar.host.url", http://20.193.128.173:9000 // - property "sonar.projectName", "sample" - property "sonar.projectKey", "sample" - } - } From 5578adf931f8e5c6e4946258ed9f3647774d123b Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 11 Aug 2022 08:38:27 +0530 Subject: [PATCH 04/55] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 55ff3b2..89fdfcb 100644 --- a/pom.xml +++ b/pom.xml @@ -54,11 +54,11 @@ nexusdeploymentrepo - http://34.122.147.224:8081/repository/maven-snapshots/ + http://52.140.6.198:8081/repository/maven-snapshots/ nexusdeploymentrepo - http://34.122.147.224:8081/repository/maven-releases/ + http://52.140.6.198:8081/repository/advisingbank-release/ From 012196b168d9dc0645ed3c3e48d79a5dfae1ec78 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:41:28 +0530 Subject: [PATCH 05/55] Create template.yaml Updating params --- template.yaml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 template.yaml diff --git a/template.yaml b/template.yaml new file mode 100644 index 0000000..1362899 --- /dev/null +++ b/template.yaml @@ -0,0 +1,62 @@ +version: 1 + +name: Container Build +description: "This will create a multibranch pipeline job for container builds" + +type: pipeline-template +templateType: MULTIBRANCH + +parameters: + - name: github_organization + type: string + displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory) + + - name: github_repo + type: string + displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory) + + - name: headWildcardFilterIncludes + type: string + displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*" + + - name: headWildcardFilterExcludes + type: string + displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*" + + - name: github_creds + type: credentials + displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory) + + - name: dockerfiles + type: string + displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional) + + - name: build_arguments + type: string + displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional) + + - name: docker_tag + type: string + displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory) + +multibranch: + branchSource: + github: + repoOwner: ${github_organization} + repository: ${github_repo} + credentialsId: ${github_creds} + traits: + - gitHubBranchDiscovery: + strategyId: 3 + - headWildcardFilter: + includes: ${headWildcardFilterIncludes} + excludes: ${headWildcardFilterExcludes} + + strategy: + $class: DefaultBranchPropertyStrategy # All branches get the same properties + props: + - $class: NoTriggerBranchProperty # Suppress automatic SCM triggering + + orphanedItemStrategy: + daysToKeep: 60 + scanRepositoryInterval: 15 minutes From 10db74c5c916282bdbdb86fbeb6543d3550e7a0a Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:57:21 +0530 Subject: [PATCH 06/55] Update Jenkinsfile --- Jenkinsfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 87e4834..9fcf6f6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,15 @@ pipeline{ agent any stages{ + stage ('cleanWs & checkout scm') { + steps { + script { + deleteDir() + cleanWs() + checkout scm + } + } + } stage("Sonarqube analysis"){ steps{ script{ From 94acd5d3e088141b977780404b4289e56f543806 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 10:14:56 +0530 Subject: [PATCH 07/55] Create pipeline_config.groovy --- pipeline_config.groovy | 1 + 1 file changed, 1 insertion(+) create mode 100644 pipeline_config.groovy diff --git a/pipeline_config.groovy b/pipeline_config.groovy new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pipeline_config.groovy @@ -0,0 +1 @@ + From 7a4b1db5a9d51b2257de7124d7b1154294b41e71 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 10:20:50 +0530 Subject: [PATCH 08/55] Update pipeline_config.groovy --- pipeline_config.groovy | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 8b13789..ee36f25 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -1 +1,62 @@ +version: 1 +//name: Container Build +description: "This will create a multibranch pipeline job for container builds" + +type: pipeline-template +templateType: MULTIBRANCH + +parameters: + - name: github_organization + type: string + displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory) + + - name: github_repo + type: string + displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory) + + - name: headWildcardFilterIncludes + type: string + displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*" + + - name: headWildcardFilterExcludes + type: string + displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*" + + - name: github_creds + type: credentials + displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory) + + - name: dockerfiles + type: string + displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional) + + - name: build_arguments + type: string + displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional) + + - name: docker_tag + type: string + displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory) + +multibranch: + branchSource: + github: + repoOwner: ${github_organization} + repository: ${github_repo} + credentialsId: ${github_creds} + traits: + - gitHubBranchDiscovery: + strategyId: 3 + - headWildcardFilter: + includes: ${headWildcardFilterIncludes} + excludes: ${headWildcardFilterExcludes} + + strategy: + $class: DefaultBranchPropertyStrategy # All branches get the same properties + props: + - $class: NoTriggerBranchProperty # Suppress automatic SCM triggering + + orphanedItemStrategy: + daysToKeep: 60 + scanRepositoryInterval: 15 minutes From d98b946a100383590fa5d67f917c8b2d0a4f52bb Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 10:21:43 +0530 Subject: [PATCH 09/55] Update Jenkinsfile --- Jenkinsfile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9fcf6f6..87e4834 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,6 @@ pipeline{ agent any stages{ - stage ('cleanWs & checkout scm') { - steps { - script { - deleteDir() - cleanWs() - checkout scm - } - } - } stage("Sonarqube analysis"){ steps{ script{ From 4986c0618fb523ead7daf7eff77f2858bd6a01f8 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:02:22 +0530 Subject: [PATCH 10/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 87e4834..b59e81d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline{ stage("Sonarqube analysis"){ steps{ script{ - withSonarQubeEnv(credentialsId: 'new_sonar') { + withSonarQubeEnv(credentialsId: 'mysorarqube') { sh 'mvn sonar:sonar' } } From 3174e5d905a829378240d01a66ba1f5cebf13afd Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:11:08 +0530 Subject: [PATCH 11/55] Update pipeline_config.groovy --- pipeline_config.groovy | 81 ++++++++++-------------------------------- 1 file changed, 19 insertions(+), 62 deletions(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index ee36f25..63af3ad 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -1,62 +1,19 @@ -version: 1 - -//name: Container Build -description: "This will create a multibranch pipeline job for container builds" - -type: pipeline-template -templateType: MULTIBRANCH - -parameters: - - name: github_organization - type: string - displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory) - - - name: github_repo - type: string - displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory) - - - name: headWildcardFilterIncludes - type: string - displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*" - - - name: headWildcardFilterExcludes - type: string - displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*" - - - name: github_creds - type: credentials - displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory) - - - name: dockerfiles - type: string - displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional) - - - name: build_arguments - type: string - displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional) - - - name: docker_tag - type: string - displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory) - -multibranch: - branchSource: - github: - repoOwner: ${github_organization} - repository: ${github_repo} - credentialsId: ${github_creds} - traits: - - gitHubBranchDiscovery: - strategyId: 3 - - headWildcardFilter: - includes: ${headWildcardFilterIncludes} - excludes: ${headWildcardFilterExcludes} - - strategy: - $class: DefaultBranchPropertyStrategy # All branches get the same properties - props: - - $class: NoTriggerBranchProperty # Suppress automatic SCM triggering - - orphanedItemStrategy: - daysToKeep: 60 - scanRepositoryInterval: 15 minutes +def buildJar() { + echo "building the application..." + sh 'mvn package' +} + +def buildImage() { + echo "building the docker image..." + withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { + sh 'docker build -t maven--java/demo-app:jma-2.0 .' + sh "echo $PASS | docker login -u $USER --password-stdin" + sh 'docker push maven--java/demo-app:jma-2.0' + } +} + +def deployApp() { + echo 'deploying the application...' +} + +return this From df9a7fb30e2c083ee9fc44a2218ba7370f5c1d7a Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:14:25 +0530 Subject: [PATCH 12/55] Update Jenkinsfile --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index b59e81d..c73928e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,6 +9,14 @@ pipeline{ } } } + stage("Build jar") { + steps { + script { + echo "building jar" + gv.buildJar() + } + } + } } } post{ From b27e56c6d27ef963b1c55baa9ca449e9483ac399 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:16:52 +0530 Subject: [PATCH 13/55] Update Jenkinsfile --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c73928e..ac5a968 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,13 @@ pipeline{ agent any stages{ + stage("init") { + steps { + script { + gv = load "pipeline_config.groovy" + } + } + } stage("Sonarqube analysis"){ steps{ script{ From cfe9e4b871b706b2c8983ca2a62d9ef740f699df Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:20:23 +0530 Subject: [PATCH 14/55] Update Jenkinsfile --- Jenkinsfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac5a968..623142a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,6 @@ pipeline{ agent any stages{ - stage("init") { - steps { - script { - gv = load "pipeline_config.groovy" - } - } - } stage("Sonarqube analysis"){ steps{ script{ @@ -19,6 +12,7 @@ pipeline{ stage("Build jar") { steps { script { + gv = load "pipeline_config.groovy" echo "building jar" gv.buildJar() } From 1d4e17f5720d352c7eb9ec4c5f021ddac3f08ef0 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:43:05 +0530 Subject: [PATCH 15/55] Update Jenkinsfile --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 623142a..f5d194b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +def gv + pipeline{ agent any stages{ From 3a1e6439ab9ad60b5160f7da7131a03efcd669f5 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:13:07 +0530 Subject: [PATCH 16/55] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index f5d194b..ad8e14e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,4 @@ +@Library('java-maven') _ def gv pipeline{ From 7452d83cf752f3484dcb9064ad5f5434326c693f Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:15:24 +0530 Subject: [PATCH 17/55] Create config.groovy --- vars/config.groovy | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 vars/config.groovy diff --git a/vars/config.groovy b/vars/config.groovy new file mode 100644 index 0000000..63af3ad --- /dev/null +++ b/vars/config.groovy @@ -0,0 +1,19 @@ +def buildJar() { + echo "building the application..." + sh 'mvn package' +} + +def buildImage() { + echo "building the docker image..." + withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { + sh 'docker build -t maven--java/demo-app:jma-2.0 .' + sh "echo $PASS | docker login -u $USER --password-stdin" + sh 'docker push maven--java/demo-app:jma-2.0' + } +} + +def deployApp() { + echo 'deploying the application...' +} + +return this From 12b2765735e37faa66525d7f6c3484b000c4ddf8 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:16:55 +0530 Subject: [PATCH 18/55] Create params.yaml --- vars/params.yaml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 vars/params.yaml diff --git a/vars/params.yaml b/vars/params.yaml new file mode 100644 index 0000000..1362899 --- /dev/null +++ b/vars/params.yaml @@ -0,0 +1,62 @@ +version: 1 + +name: Container Build +description: "This will create a multibranch pipeline job for container builds" + +type: pipeline-template +templateType: MULTIBRANCH + +parameters: + - name: github_organization + type: string + displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory) + + - name: github_repo + type: string + displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory) + + - name: headWildcardFilterIncludes + type: string + displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*" + + - name: headWildcardFilterExcludes + type: string + displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*" + + - name: github_creds + type: credentials + displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory) + + - name: dockerfiles + type: string + displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional) + + - name: build_arguments + type: string + displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional) + + - name: docker_tag + type: string + displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory) + +multibranch: + branchSource: + github: + repoOwner: ${github_organization} + repository: ${github_repo} + credentialsId: ${github_creds} + traits: + - gitHubBranchDiscovery: + strategyId: 3 + - headWildcardFilter: + includes: ${headWildcardFilterIncludes} + excludes: ${headWildcardFilterExcludes} + + strategy: + $class: DefaultBranchPropertyStrategy # All branches get the same properties + props: + - $class: NoTriggerBranchProperty # Suppress automatic SCM triggering + + orphanedItemStrategy: + daysToKeep: 60 + scanRepositoryInterval: 15 minutes From 939cc807aa246d5222c444fd212446db94102c23 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:35:01 +0530 Subject: [PATCH 19/55] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ad8e14e..1c6201c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,5 @@ @Library('java-maven') _ + def gv pipeline{ @@ -6,7 +7,6 @@ pipeline{ stages{ stage("Sonarqube analysis"){ steps{ - script{ withSonarQubeEnv(credentialsId: 'mysorarqube') { sh 'mvn sonar:sonar' } @@ -22,7 +22,6 @@ pipeline{ } } } - } post{ always{ echo "========always========" From 1c29085537e0a47c3d2f0d77fcb1c63dfa6764b5 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:39:30 +0530 Subject: [PATCH 20/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1c6201c..9a2b20f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline{ stages{ stage("Sonarqube analysis"){ steps{ - withSonarQubeEnv(credentialsId: 'mysorarqube') { + withSonarQubeEnv(credentialsId: 'mysorarqube' installationName: 'sample_java') { sh 'mvn sonar:sonar' } } From d61c2ed6c60b246e7296414f4042167c11a3b9cc Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:41:00 +0530 Subject: [PATCH 21/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9a2b20f..4054429 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline{ stages{ stage("Sonarqube analysis"){ steps{ - withSonarQubeEnv(credentialsId: 'mysorarqube' installationName: 'sample_java') { + withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') { sh 'mvn sonar:sonar' } } From d90f6f56ed06e9a5f7ce036ea04b79488dcdfd85 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:50:39 +0530 Subject: [PATCH 22/55] Create dockerBuild.groovy --- vars/dockerBuild.groovy | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 vars/dockerBuild.groovy diff --git a/vars/dockerBuild.groovy b/vars/dockerBuild.groovy new file mode 100644 index 0000000..9804d4e --- /dev/null +++ b/vars/dockerBuild.groovy @@ -0,0 +1,19 @@ +def login() { + withCredentials([usernamePassword(credentialsId: '******', usernameVariable: '*****', passwordVariable: '*****')]) { + sh """ + docker login --username="${hubUsername}" --password="${hubPassword}" + """ + } +} + +def build(String tag) { + sh """ + docker build -t "${tag}" . + """ +} + +def push(String tag) { + sh """ + docker push "${tag}" + """ +} From a72b8e4c928c80546b986443a0c9438d5d935723 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:59:34 +0530 Subject: [PATCH 23/55] Update Jenkinsfile --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 4054429..b5a05d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,12 @@ pipeline{ } } } + stage("Roll Back"){ + when{ + expression { + hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true + } + } } post{ always{ From 969bb44cc50c5e27ff20544f662745a720978cad Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 13:02:27 +0530 Subject: [PATCH 24/55] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index b5a05d6..7891846 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,4 +39,5 @@ pipeline{ echo "========pipeline execution failed========" } } + } } From 715f51cd78c241704bcf94745423f136f74f8305 Mon Sep 17 00:00:00 2001 From: bhaskar99636 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:14:44 +0530 Subject: [PATCH 25/55] Update Jenkinsfile --- Jenkinsfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7891846..f10dfed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,10 +22,12 @@ pipeline{ } } stage("Roll Back"){ - when{ - expression { - hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true - } + steps { + when{ + expression { + hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true + } + } } } post{ From df676f476043eba81de2784755836345502d5f54 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:21:41 +0530 Subject: [PATCH 26/55] Update Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f10dfed..4453f70 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,8 @@ pipeline{ } } } - post{ + stage ("post build action"){ + post{ always{ echo "========always========" } @@ -41,5 +42,6 @@ pipeline{ echo "========pipeline execution failed========" } } - } + } +} } From c3392cf5670c53f39fcb8441291b3a6917f249fb Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:28:42 +0530 Subject: [PATCH 27/55] Update config.groovy --- vars/config.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vars/config.groovy b/vars/config.groovy index 63af3ad..ce5f7bd 100644 --- a/vars/config.groovy +++ b/vars/config.groovy @@ -1,8 +1,12 @@ def buildJar() { echo "building the application..." sh 'mvn package' -} +} +def rollback() { + echo "roll back to previous version" + hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true +} def buildImage() { echo "building the docker image..." withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { From a126ba2e091b04ee0e5a287fd8cf158e376b44e8 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:30:33 +0530 Subject: [PATCH 28/55] Update Jenkinsfile --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4453f70..5318561 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline{ stage("Build jar") { steps { script { - gv = load "pipeline_config.groovy" + gv = load "config.groovy" echo "building jar" gv.buildJar() } @@ -23,11 +23,14 @@ pipeline{ } stage("Roll Back"){ steps { + script { + gv = load "config.groovy" when{ expression { - hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true + gv.rollback() } } + } } } stage ("post build action"){ From 142e9603ad7f8947198a98266f9d1eaedb5946ad Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:32:37 +0530 Subject: [PATCH 29/55] Update Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5318561..d2373ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,8 @@ pipeline{ } } stage ("post build action"){ - post{ + steps { + post{ always{ echo "========always========" } @@ -46,5 +47,6 @@ pipeline{ } } } -} + } + } } From 887cd81cca6107b6914730f22a1542f0116b6701 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:16:25 +0530 Subject: [PATCH 30/55] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2373ad..102ee3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline{ stage("Build jar") { steps { script { - gv = load "config.groovy" + gv = load "pipeline_config.groovy" echo "building jar" gv.buildJar() } @@ -24,7 +24,7 @@ pipeline{ stage("Roll Back"){ steps { script { - gv = load "config.groovy" + gv = load "pipeline_config.groovy" when{ expression { gv.rollback() From b8fd86769ecf2afe89edc2df1d1342b82ab94e52 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:17:37 +0530 Subject: [PATCH 31/55] Update pipeline_config.groovy --- pipeline_config.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 63af3ad..ce5f7bd 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -1,8 +1,12 @@ def buildJar() { echo "building the application..." sh 'mvn package' -} +} +def rollback() { + echo "roll back to previous version" + hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true +} def buildImage() { echo "building the docker image..." withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { From c252ce7d3215a99152c34a5b7f91c024b2983dad Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 31 Aug 2022 11:16:56 +0530 Subject: [PATCH 32/55] Update Jenkinsfile --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 102ee3b..508cbd6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,10 @@ def gv pipeline{ agent any + tools { + maven "MAVEN" + jdk "JDK" + } stages{ stage("Sonarqube analysis"){ steps{ From 0ff1d80fa803f243d15b90ac692ebbf5950ff78e Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 7 Sep 2022 11:10:23 +0530 Subject: [PATCH 33/55] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 508cbd6..bc89798 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,6 @@ def gv pipeline{ agent any tools { - maven "MAVEN" jdk "JDK" } stages{ From 4b3b67b8e68425b80bc4bd0aa3ccb82d9a4219cb Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 7 Sep 2022 20:17:26 +0530 Subject: [PATCH 34/55] Update Jenkinsfile --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc89798..9996db3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,12 +27,12 @@ pipeline{ stage("Roll Back"){ steps { script { - gv = load "pipeline_config.groovy" - when{ - expression { - gv.rollback() - } - } + if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { + if (currentBuild.resultIsBetterOrEqualTo( + currentBuild.getPreviousBuild().result)) { + echo 'build has been fixed + } +} } } } From ee9b56928886bd0baac7aacbb673c1459bdc9966 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 7 Sep 2022 20:18:45 +0530 Subject: [PATCH 35/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9996db3..49dc90a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ pipeline{ if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { if (currentBuild.resultIsBetterOrEqualTo( currentBuild.getPreviousBuild().result)) { - echo 'build has been fixed + echo 'build has been fixed' } } } From c7f10b9d0429792e5642121bc8b2fa234aef7dd0 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 7 Sep 2022 20:28:00 +0530 Subject: [PATCH 36/55] Update Jenkinsfile --- Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 49dc90a..de1a4c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,8 +36,7 @@ pipeline{ } } } - stage ("post build action"){ - steps { + post{ always{ echo "========always========" @@ -49,7 +48,6 @@ pipeline{ echo "========pipeline execution failed========" } } - } - } + } } From 65d84fc207510198eaa23cd90bab05ff4fee6e84 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Wed, 7 Sep 2022 20:30:38 +0530 Subject: [PATCH 37/55] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index de1a4c2..816a44c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,7 +36,7 @@ pipeline{ } } } - + } post{ always{ echo "========always========" @@ -49,5 +49,5 @@ pipeline{ } } - } + } From b0d8ab137f76649f7e5e62f9b716d9048dd61515 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:55:32 +0530 Subject: [PATCH 38/55] Update pipeline_config.groovy --- pipeline_config.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index ce5f7bd..4b7c48b 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -5,7 +5,12 @@ def buildJar() { def rollback() { echo "roll back to previous version" - hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true + if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { + if (currentBuild.resultIsBetterOrEqualTo( + currentBuild.getPreviousBuild().result)) { + echo 'build has been fixed' + } + } } def buildImage() { echo "building the docker image..." From dab6dcd620e64f49e3777a32fdd2d37be6ec9c7d Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:57:55 +0530 Subject: [PATCH 39/55] Update Jenkinsfile --- Jenkinsfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 816a44c..373eb64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,12 +27,8 @@ pipeline{ stage("Roll Back"){ steps { script { - if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { - if (currentBuild.resultIsBetterOrEqualTo( - currentBuild.getPreviousBuild().result)) { - echo 'build has been fixed' - } -} + echo "roll back to previous version" + gv.rollback() } } } From eba0476bacff4791f5243be1e622a71d21e40983 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:42:47 +0530 Subject: [PATCH 40/55] Update pipeline_config.groovy --- pipeline_config.groovy | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 4b7c48b..157eecf 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -12,6 +12,16 @@ def rollback() { } } } +def tag version() { + void gitTag(Version releaseVersion) { + sshagent(['devops_deploy_DEV']) { + shell 'git tag -d \$(git tag)' + shell 'git fetch --tags' + echo "New release version ${releaseVersion.normalVersion}" + shell "git tag -fa ${releaseVersion.normalVersion} -m 'Release version ${releaseVersion.normalVersion}'" + } + } + } def buildImage() { echo "building the docker image..." withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { From 99e671e71e7fad507df6ae739516bc06c23d5036 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:47:33 +0530 Subject: [PATCH 41/55] Update Jenkinsfile --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 373eb64..4b9390c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,15 @@ pipeline{ } } } - stage("Roll Back"){ + stage("releaseVersion"){ + steps { + script { + echo "git tag" + gv.tag version() + } + } + } + stage("Roll Back"){ steps { script { echo "roll back to previous version" From b06f67e62509bff9f475ca644cd0407bc51afa74 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:39:16 +0530 Subject: [PATCH 42/55] Update pipeline_config.groovy --- pipeline_config.groovy | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 157eecf..7217293 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -3,6 +3,12 @@ def buildJar() { sh 'mvn package' } +def qualityanalysis() { + withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') { + sh 'mvn sonar:sonar' + } + } + def rollback() { echo "roll back to previous version" if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { From b85db3606c7e2eb94bca19a8cf3174bdca479ff8 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:46:50 +0530 Subject: [PATCH 43/55] Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4b9390c..323aad9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,9 +10,7 @@ pipeline{ stages{ stage("Sonarqube analysis"){ steps{ - withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') { - sh 'mvn sonar:sonar' - } + gv.qualityanalysis() } } stage("Build jar") { From 215db04b0e7cd8c6eb435b026a88ee68ddac4e20 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:48:35 +0530 Subject: [PATCH 44/55] Update pipeline_config.groovy --- pipeline_config.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 7217293..5512982 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -4,6 +4,7 @@ def buildJar() { } def qualityanalysis() { + echo "sonarQube code quality check" withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') { sh 'mvn sonar:sonar' } From edd254a80230abd9226063366a75b0bf1b2d44c6 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:49:48 +0530 Subject: [PATCH 45/55] Update Jenkinsfile --- Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 323aad9..b05c37c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,10 @@ pipeline{ stages{ stage("Sonarqube analysis"){ steps{ - gv.qualityanalysis() + script { + echo "sonarQube code quality check" + gv.qualityanalysis() + } } } stage("Build jar") { From cbfdbd6f9b11b3518160b4eeadc1ae4bed4e3771 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:51:01 +0530 Subject: [PATCH 46/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b05c37c..9c09876 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline{ stage("Sonarqube analysis"){ steps{ script { + gv = load "pipeline_config.groovy" echo "sonarQube code quality check" gv.qualityanalysis() } @@ -19,7 +20,6 @@ pipeline{ stage("Build jar") { steps { script { - gv = load "pipeline_config.groovy" echo "building jar" gv.buildJar() } From ccc845939358d749e22aa80bd082282393b39693 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:59:28 +0530 Subject: [PATCH 47/55] Update pipeline_config.groovy --- pipeline_config.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 5512982..b20a9e8 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -6,7 +6,7 @@ def buildJar() { def qualityanalysis() { echo "sonarQube code quality check" withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') { - sh 'mvn sonar:sonar' + sh 'mvn sonar:sonar' } } From 66a6c1321871c1bcee06290397050ed6d1f89c74 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Thu, 8 Sep 2022 17:49:33 +0530 Subject: [PATCH 48/55] Update pipeline_config.groovy --- pipeline_config.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index b20a9e8..50d0928 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -1,6 +1,6 @@ def buildJar() { echo "building the application..." - sh 'mvn package' + sh 'mvnpackage' } def qualityanalysis() { From 9b01376866714bf71dbe20afec2048a89bc2b925 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Mon, 12 Sep 2022 21:52:15 +0530 Subject: [PATCH 49/55] Update Jenkinsfile --- Jenkinsfile | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9c09876..31203e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,16 @@ -@Library('java-maven') _ - def gv pipeline{ agent any - tools { - jdk "JDK" - } + stages{ + stage('SCM Checkout') { + steps { + git branch: '', + credentialsId: '', + url: 'https://github.com/bhaskar99636/java--maven.git' + } + } stage("Sonarqube analysis"){ steps{ script { @@ -25,14 +28,6 @@ pipeline{ } } } - stage("releaseVersion"){ - steps { - script { - echo "git tag" - gv.tag version() - } - } - } stage("Roll Back"){ steps { script { From 25a199a37227a2660bc466aee0064bcfb8423cc5 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Mon, 12 Sep 2022 22:00:35 +0530 Subject: [PATCH 50/55] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 31203e6..1419c3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,9 +6,9 @@ pipeline{ stages{ stage('SCM Checkout') { steps { - git branch: '', - credentialsId: '', - url: 'https://github.com/bhaskar99636/java--maven.git' + git branch: 'BRANCH_NAME', + credentialsId: 'GIT_CREDS', + url: 'REPO_URL' } } stage("Sonarqube analysis"){ From 5cd27afcb556dc10b0324da64d7f28dcd223d084 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Mon, 12 Sep 2022 22:13:31 +0530 Subject: [PATCH 51/55] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1419c3d..8358d52 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,9 +6,9 @@ pipeline{ stages{ stage('SCM Checkout') { steps { - git branch: 'BRANCH_NAME', - credentialsId: 'GIT_CREDS', - url: 'REPO_URL' + git branch: '${params.BRANCH_NAME}', + credentialsId: '${params.GIT_CREDS}', + url: '${params.REPO_URL}' } } stage("Sonarqube analysis"){ From 5b8dd5d37259455b892303f401ee3434fefdd6f0 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+bhaskar99636@users.noreply.github.com> Date: Mon, 12 Sep 2022 22:19:37 +0530 Subject: [PATCH 52/55] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8358d52..e3bcfa7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline{ stage('SCM Checkout') { steps { git branch: '${params.BRANCH_NAME}', - credentialsId: '${params.GIT_CREDS}', + credentialsId: '', url: '${params.REPO_URL}' } } From a59d38eaabab7feb1d6c7090bb1327752de981a8 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+venkatd901@users.noreply.github.com> Date: Wed, 14 Sep 2022 15:30:01 +0530 Subject: [PATCH 53/55] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e3bcfa7..678aa6c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,9 +6,9 @@ pipeline{ stages{ stage('SCM Checkout') { steps { - git branch: '${params.BRANCH_NAME}', - credentialsId: '', - url: '${params.REPO_URL}' + git branch: '${params.branch_name}', + credentialsId: '${params.git_creds}', + url: '${params.git_url}' } } stage("Sonarqube analysis"){ From 8c73bda56fbe99ea1ef2abe7f3c72c6802633f54 Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+venkatd901@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:05:17 +0530 Subject: [PATCH 54/55] Update pipeline_config.groovy --- pipeline_config.groovy | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pipeline_config.groovy b/pipeline_config.groovy index 50d0928..89699cf 100644 --- a/pipeline_config.groovy +++ b/pipeline_config.groovy @@ -1,6 +1,6 @@ def buildJar() { echo "building the application..." - sh 'mvnpackage' + sh 'mvn package' } def qualityanalysis() { @@ -10,6 +10,12 @@ def qualityanalysis() { } } +def testReport(){ + echo 'Generated Test report...' + sh 'mvn test' +} + + def rollback() { echo "roll back to previous version" if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') { @@ -19,16 +25,7 @@ def rollback() { } } } -def tag version() { - void gitTag(Version releaseVersion) { - sshagent(['devops_deploy_DEV']) { - shell 'git tag -d \$(git tag)' - shell 'git fetch --tags' - echo "New release version ${releaseVersion.normalVersion}" - shell "git tag -fa ${releaseVersion.normalVersion} -m 'Release version ${releaseVersion.normalVersion}'" - } - } - } + def buildImage() { echo "building the docker image..." withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) { From 45bad094e6811c4a124bf2098675e65b74ade36e Mon Sep 17 00:00:00 2001 From: venkatd901 <90154705+venkatd901@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:37:30 +0530 Subject: [PATCH 55/55] Update Jenkinsfile --- Jenkinsfile | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 678aa6c..50cde63 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,22 +4,20 @@ pipeline{ agent any stages{ - stage('SCM Checkout') { + stage('code quality check via sonarQube') { steps { - git branch: '${params.branch_name}', - credentialsId: '${params.git_creds}', - url: '${params.git_url}' - } - } - stage("Sonarqube analysis"){ - steps{ script { - gv = load "pipeline_config.groovy" - echo "sonarQube code quality check" - gv.qualityanalysis() + if (env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'QA' ) { + echo 'I execute on the DEV and QA branch' + gv = load "pipeline_config.groovy" + echo "sonarQube code quality check" + gv.qualityanalysis() + } else { + echo 'I execute elsewhere' } } } + } stage("Build jar") { steps { script { @@ -28,7 +26,7 @@ pipeline{ } } } - stage("Roll Back"){ + stage("Roll Back") { steps { script { echo "roll back to previous version"