From b8d31c7216f22dea214be3535e7f07514446d704 Mon Sep 17 00:00:00 2001 From: vprocodeadmin-at-454285653643 Date: Tue, 25 Jun 2019 09:12:07 +0530 Subject: [PATCH 01/78] comments updated --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f138fcbfc..d53dce113 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -## Prerequisites +### Prerequisites - JDK 1.8 or later - Maven 3 or later - MySQL 5.6 or later -## Technologies +### Technologies - Spring MVC - Spring Security - Spring Data JPA - Maven - JSP - MySQL -## Database +### Database Here,we used Mysql DB MSQL DB Installation Steps for Linux ubuntu 14.04: - $ sudo apt-get update From 3e9b7b245c960a19d79e7d03bbb1ea3fecd9b30d Mon Sep 17 00:00:00 2001 From: vprocodeadmin-at-454285653643 Date: Wed, 24 Jul 2019 20:31:30 +0530 Subject: [PATCH 02/78] updated Readme file --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d53dce113..74ba9a185 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +###### ### Prerequisites - JDK 1.8 or later - Maven 3 or later From c064c803e22d6d6c7657963896a93be4ca13827b Mon Sep 17 00:00:00 2001 From: vprocodeadmin-at-454285653643 Date: Thu, 12 Sep 2019 07:51:22 +0530 Subject: [PATCH 03/78] testing git poll from jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 74ba9a185..e0aaac5ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -###### +####### ### Prerequisites - JDK 1.8 or later - Maven 3 or later From 9463c8ee33a634da2672c0656353472bb01d2bbf Mon Sep 17 00:00:00 2001 From: vprocodeadmin-at-454285653643 Date: Wed, 13 Nov 2019 09:02:45 +0530 Subject: [PATCH 04/78] Version 2 updated --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 332e952e2..5c7314062 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.visualpathit vprofile war - v1 + v2 Visualpathit VProfile Webapp http://maven.apache.org From e09c46382d620d72e83780ad76edea42040a2492 Mon Sep 17 00:00:00 2001 From: ImranT Date: Tue, 7 Jan 2020 08:07:05 +0530 Subject: [PATCH 05/78] Test git poll scm --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0aaac5ea..60d81a3de 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -####### +######## ### Prerequisites - JDK 1.8 or later - Maven 3 or later From 4b955046a9934bf54aeb41f0cbd2ab9729abcfaf Mon Sep 17 00:00:00 2001 From: ImranT Date: Tue, 4 Feb 2020 19:17:58 +0530 Subject: [PATCH 06/78] Update config.yaml fr circleci --- config.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 config.yaml diff --git a/config.yaml b/config.yaml new file mode 100644 index 000000000..c6c06e62a --- /dev/null +++ b/config.yaml @@ -0,0 +1,41 @@ +# Java Maven CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-java/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/openjdk:8-jdk + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 + + working_directory: ~/repo + + environment: + # Customize the JVM maximum heap limit + MAVEN_OPTS: -Xmx3200m + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: mvn dependency:go-offline + + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} + + # run tests! + - run: mvn integration-test From af3b291f2a10becea996de9cf403d34455b8c323 Mon Sep 17 00:00:00 2001 From: ImranT Date: Tue, 4 Feb 2020 19:20:52 +0530 Subject: [PATCH 07/78] Updated config.yaml for circleci --- config.yaml => .circleci/config.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config.yaml => .circleci/config.yaml (100%) diff --git a/config.yaml b/.circleci/config.yaml similarity index 100% rename from config.yaml rename to .circleci/config.yaml From 2cd915683cd79026946ee3783d93c5434b4f69f2 Mon Sep 17 00:00:00 2001 From: Imran DevOps Date: Mon, 13 Apr 2020 07:44:38 +0530 Subject: [PATCH 08/78] testing git poll from jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60d81a3de..1a1dc5f2a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -######## +########## ### Prerequisites - JDK 1.8 or later - Maven 3 or later From a70df784056545246f61b3cf1fcbf63b8eab4401 Mon Sep 17 00:00:00 2001 From: ImranT Date: Thu, 21 May 2020 14:46:29 +0530 Subject: [PATCH 09/78] Updated master with jenkinsfile --- Jenkinsfile | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..02f1dd984 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,60 @@ +pipeline { + agent any + stages{ + stage('Build'){ + steps { + sh 'mvn install' + } + post { + success { + echo 'Now Archiving...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + stage ('Code Analysis'){ + steps { + sh 'mvn checkstyle:checkstyle' + } + post { + success { + echo 'Generated Analysis Result' + } + } + } + stage ('Copy Artifact to Nexus Job'){ + steps { + sh 'cp /var/lib/jenkins/workspace/vprofile-pipeline/target/vprofile-v2.war /var/lib/jenkins/workspace/vprofile-nexus-versioning/vprofile-v2.war' + } + post { + success { + echo 'Artifact Copied' + } + } + } + stage ('Nexus Versioning'){ + steps { + build job: 'vprofile-nexus-versioning' + } + } + + stage ('Copy Artifact to Staging Deploy Job'){ + steps { + sh 'cp /var/lib/jenkins/workspace/vprofile-pipeline/target/vprofile-v2.war /var/lib/jenkins/workspace/vprofile-deploy-to-staging/vprofile-v2.war' + } + post { + success { + echo 'Artifact Copied' + } + } + } + + stage ('Staging Deployment'){ + steps { + build job: 'vprofile-deploy-to-staging' + } + } + } + + + } From 1b5bf8f9cb0376151d61c92ddd4352460155c19b Mon Sep 17 00:00:00 2001 From: ImranT Date: Mon, 29 Jun 2020 06:44:10 +0530 Subject: [PATCH 10/78] test commit 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a1dc5f2a..658e6a090 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -########## +############ ### Prerequisites - JDK 1.8 or later - Maven 3 or later From 73f16fc479dd425659aa26ed61122a25d47a00e8 Mon Sep 17 00:00:00 2001 From: ImranT Date: Mon, 29 Jun 2020 06:45:57 +0530 Subject: [PATCH 11/78] Revert "test commit 1" This reverts commit 1b5bf8f9cb0376151d61c92ddd4352460155c19b. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 658e6a090..1a1dc5f2a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -############ +########## ### Prerequisites - JDK 1.8 or later - Maven 3 or later From caf3e51dc4e5c02b24aec3ce4f0a6d316e1bbc6d Mon Sep 17 00:00:00 2001 From: imran Date: Fri, 10 Jul 2020 23:51:03 +0530 Subject: [PATCH 12/78] Updated README.md file --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1a1dc5f2a..d53dce113 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -########## ### Prerequisites - JDK 1.8 or later - Maven 3 or later From fd048b4db92e4fa5a4cb3a94fc4fdf9263b5f432 Mon Sep 17 00:00:00 2001 From: imran Date: Fri, 10 Jul 2020 23:53:31 +0530 Subject: [PATCH 13/78] Testing eclipse integration --- README.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d53dce113..84ce5d07f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +#### ### Prerequisites - JDK 1.8 or later - Maven 3 or later diff --git a/pom.xml b/pom.xml index 5c7314062..332e952e2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.visualpathit vprofile war - v2 + v1 Visualpathit VProfile Webapp http://maven.apache.org From f1d807487748fa9237a343c9ad605635904448ee Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Sat, 11 Jul 2020 00:23:12 +0530 Subject: [PATCH 14/78] Pipeline as a code for CI --- Jenkinsfile | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 02f1dd984..691f25c54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,29 +32,31 @@ pipeline { } } } - stage ('Nexus Versioning'){ - steps { - build job: 'vprofile-nexus-versioning' - } + freeStyleJob('NexusArtifactUploaderJob') { + steps { + nexusArtifactUploader { + nexusVersion('nexus3') + protocol('http') + nexusUrl('172.31.22.110:8080') + groupId('sp.sd') + version('2.4') + repository('vprofile-repo') + credentialsId('ff8f0688-e38e-4cc6-938c-dcbb8d8cb2df') + artifact { + artifactId('nexus-artifact-uploader') + type('war') + classifier('debug') + file('vprofile-v2.war') + } + } } + } + - stage ('Copy Artifact to Staging Deploy Job'){ - steps { - sh 'cp /var/lib/jenkins/workspace/vprofile-pipeline/target/vprofile-v2.war /var/lib/jenkins/workspace/vprofile-deploy-to-staging/vprofile-v2.war' - } - post { - success { - echo 'Artifact Copied' - } - } - } - stage ('Staging Deployment'){ - steps { - build job: 'vprofile-deploy-to-staging' - } - } + } } + From 81611eb8db074adb17c095bf477fced1a8ac89d7 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Sat, 11 Jul 2020 00:26:31 +0530 Subject: [PATCH 15/78] updated artifact version to v2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 332e952e2..5c7314062 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.visualpathit vprofile war - v1 + v2 Visualpathit VProfile Webapp http://maven.apache.org From d2f10de8e2eebcfdcce361cd619258bc86ebf586 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Sat, 11 Jul 2020 00:47:56 +0530 Subject: [PATCH 16/78] jenkinsfile updated with nexus --- Jenkinsfile | 64 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 691f25c54..87749edcd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,12 @@ pipeline { agent any + environment { + NEXUS_VERSION = "nexus3" + NEXUS_PROTOCOL = "http" + NEXUS_URL = "172.31.22.110:8081" + NEXUS_REPOSITORY = "vprofile-repo" + NEXUS_CREDENTIAL_ID = "ff8f0688-e38e-4cc6-938c-dcbb8d8cb2df" + } stages{ stage('Build'){ steps { @@ -22,35 +29,42 @@ pipeline { } } } - stage ('Copy Artifact to Nexus Job'){ + + stage("Publish to Nexus Repository Manager") { steps { - sh 'cp /var/lib/jenkins/workspace/vprofile-pipeline/target/vprofile-v2.war /var/lib/jenkins/workspace/vprofile-nexus-versioning/vprofile-v2.war' - } - post { - success { - echo 'Artifact Copied' + script { + pom = readMavenPom file: "pom.xml"; + filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); + echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" + artifactPath = filesByGlob[0].path; + artifactExists = fileExists artifactPath; + if(artifactExists) { + echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; + nexusArtifactUploader( + nexusVersion: NEXUS_VERSION, + protocol: NEXUS_PROTOCOL, + nexusUrl: NEXUS_URL, + groupId: pom.groupId, + version: pom.version, + repository: NEXUS_REPOSITORY, + credentialsId: NEXUS_CREDENTIAL_ID, + artifacts: [ + [artifactId: pom.artifactId, + classifier: '', + file: artifactPath, + type: pom.packaging], + [artifactId: pom.artifactId, + classifier: '', + file: "pom.xml", + type: "pom"] + ] + ); + } else { + error "*** File: ${artifactPath}, could not be found"; + } } } } - freeStyleJob('NexusArtifactUploaderJob') { - steps { - nexusArtifactUploader { - nexusVersion('nexus3') - protocol('http') - nexusUrl('172.31.22.110:8080') - groupId('sp.sd') - version('2.4') - repository('vprofile-repo') - credentialsId('ff8f0688-e38e-4cc6-938c-dcbb8d8cb2df') - artifact { - artifactId('nexus-artifact-uploader') - type('war') - classifier('debug') - file('vprofile-v2.war') - } - } - } - } From 2fab30e9ebae2c03a43f8fa18410798d04a3f01f Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Sat, 11 Jul 2020 01:03:09 +0530 Subject: [PATCH 17/78] BuildAndTest in jekinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 87749edcd..29d5be6e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { NEXUS_CREDENTIAL_ID = "ff8f0688-e38e-4cc6-938c-dcbb8d8cb2df" } stages{ - stage('Build'){ + stage('BuildAndTest'){ steps { sh 'mvn install' } From eda9bae6ef062426e9054373758643c6844be0d7 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Wed, 22 Jul 2020 16:58:09 +0530 Subject: [PATCH 18/78] Updated pom.xml with nexusrepo url --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 5c7314062..2fd523d4a 100644 --- a/pom.xml +++ b/pom.xml @@ -156,5 +156,11 @@ + + + vprofile-grp-repo + http://${NEXUSIP}:${NEXUSPORT}/repository/${REPONAME}/ + + From bb9bf7842913fc6c20897e93a17e1e14b48df2b1 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 08:56:35 +0530 Subject: [PATCH 19/78] Jenkinsfile with sonar --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 29d5be6e0..01f22babd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,6 +29,22 @@ pipeline { } } } + + stage('Sonarqube') { + environment { + scannerHome = tool 'sonarscanner4' + } + + steps { + withSonarQubeEnv('sonar-pro') { + sh "${scannerHome}/bin/sonar-scanner" + } + + timeout(time: 10, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + } + } stage("Publish to Nexus Repository Manager") { steps { From bbbddfadde74d03106027470f3e5afd9286c25dd Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 09:11:54 +0530 Subject: [PATCH 20/78] updated jenkinsfile with nexusid --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 01f22babd..dc0944f36 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,9 +3,9 @@ pipeline { environment { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" - NEXUS_URL = "172.31.22.110:8081" - NEXUS_REPOSITORY = "vprofile-repo" - NEXUS_CREDENTIAL_ID = "ff8f0688-e38e-4cc6-938c-dcbb8d8cb2df" + NEXUS_URL = "172.31.40.209:8081" + NEXUS_REPOSITORY = "vprofile-release" + NEXUS_CREDENTIAL_ID = "nexuslogin" } stages{ stage('BuildAndTest'){ From a4b8dbdff5c283338ea1874c452da123a4b27845 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 09:26:30 +0530 Subject: [PATCH 21/78] Updated jenkinsfile with sonarproperties --- Jenkinsfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dc0944f36..f99d7021a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,14 @@ pipeline { steps { withSonarQubeEnv('sonar-pro') { - sh "${scannerHome}/bin/sonar-scanner" + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile-repo \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' } timeout(time: 10, unit: 'MINUTES') { From 59ef103dcede6df13e1adc0192847b26f7be7660 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 10:11:38 +0530 Subject: [PATCH 22/78] testing artificat versioning in jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f99d7021a..8a41b2d7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,7 @@ pipeline { NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" + ARTVERSION = "$BUILD_ID" } stages{ stage('BuildAndTest'){ @@ -68,7 +69,7 @@ pipeline { protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, groupId: pom.groupId, - version: pom.version, + version: pom.version-ARTVERSION, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, artifacts: [ From f18944f6e871565440f62b619e886b67302c357e Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 10:26:04 +0530 Subject: [PATCH 23/78] test 2 for versioning artificat in pipeline --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8a41b2d7d..32e614b15 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -63,7 +63,7 @@ pipeline { artifactPath = filesByGlob[0].path; artifactExists = fileExists artifactPath; if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; + echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; nexusArtifactUploader( nexusVersion: NEXUS_VERSION, protocol: NEXUS_PROTOCOL, From f8fde651b74ae413dbd964dc52cac69f4c0c5842 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 10:33:32 +0530 Subject: [PATCH 24/78] test 3 for versioning artificat in pipeline --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 32e614b15..4e3403803 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,7 +69,7 @@ pipeline { protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, groupId: pom.groupId, - version: pom.version-ARTVERSION, + version: {env.BUILD_ID}, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, artifacts: [ From a634b9fb6d3fc1c7ce18580503c165af9c4ef510 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 10:37:51 +0530 Subject: [PATCH 25/78] test 4 for versioning artificat in pipeline --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4e3403803..d5fabe7f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "$BUILD_ID" + ARTVERSION = "${env.BUILD_ID}" } stages{ stage('BuildAndTest'){ @@ -69,7 +69,7 @@ pipeline { protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, groupId: pom.groupId, - version: {env.BUILD_ID}, + version: ARTVERSION, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, artifacts: [ From 8789badb932580604f20bfab75e552713ba421c9 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 11:40:19 +0530 Subject: [PATCH 26/78] Corrected jenkinsfile structure --- Jenkinsfile | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d5fabe7f8..458b58738 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,22 @@ pipeline { - agent any - environment { + + agent any + + tools { + maven "Maven" + } + + environment { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "${env.BUILD_ID}" + ARTVERSION = "${env.BUILD_ID}" } + stages{ + stage('BuildAndTest'){ steps { sh 'mvn install' @@ -20,7 +28,8 @@ pipeline { } } } - stage ('Code Analysis'){ + + stage ('Code Analysis'){ steps { sh 'mvn checkstyle:checkstyle' } @@ -31,8 +40,9 @@ pipeline { } } - stage('Sonarqube') { - environment { + stage('Sonarqube') { + + environment { scannerHome = tool 'sonarscanner4' } @@ -53,8 +63,8 @@ pipeline { } } } - - stage("Publish to Nexus Repository Manager") { + + stage("Publish to Nexus Repository Manager") { steps { script { pom = readMavenPom file: "pom.xml"; @@ -83,18 +93,16 @@ pipeline { type: "pom"] ] ); - } else { + } + else { error "*** File: ${artifactPath}, could not be found"; } } } } - - - - } - } + +} From a7e76a2d1a053a4b6066bc64969e362d0679d533 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:01:42 +0530 Subject: [PATCH 27/78] updated maven3 tool in Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 458b58738..8281bf061 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { agent any tools { - maven "Maven" + maven "maven3" } environment { From 2fda0d15f337d39e918be08209231474a2a1c350 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:07:34 +0530 Subject: [PATCH 28/78] commented maven3 tool in Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8281bf061..69f1652cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,11 @@ pipeline { agent any - +/* tools { maven "maven3" } - +*/ environment { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" From 8ee32b2f2ccfb8577ebe160a8ab026cf7aac1ca0 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:23:28 +0530 Subject: [PATCH 29/78] Seprated Build & test stage in Jenkinsfile --- Jenkinsfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 69f1652cc..eaef6ea7b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,9 +17,9 @@ pipeline { stages{ - stage('BuildAndTest'){ + stage('BUILD'){ steps { - sh 'mvn install' + sh 'mvn package' } post { success { @@ -28,6 +28,12 @@ pipeline { } } } + + stage('TEST'){ + steps { + sh 'mvn test' + } + } stage ('Code Analysis'){ steps { From 2c85b93fdd30da36cfe7f2dc40d423ac31f25273 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:26:28 +0530 Subject: [PATCH 30/78] UPDATED PHASE NAMES --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eaef6ea7b..d6075d252 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { } } - stage ('Code Analysis'){ + stage ('CODE ANALYSIS WITH CHECKSTYLE'){ steps { sh 'mvn checkstyle:checkstyle' } @@ -46,7 +46,7 @@ pipeline { } } - stage('Sonarqube') { + stage('CODE ANALYSIS with SONARQUBE') { environment { scannerHome = tool 'sonarscanner4' From 33cb01613f5015bc3b2e556c880c222dd6564c5e Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:29:01 +0530 Subject: [PATCH 31/78] CHANGED REPO NAME OF NEXUS --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d6075d252..914e69c14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-release" + NEXUS_REPOSITORY = "vprofile-grp-repo" NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" } From a0ddd280b130774bdc54bb3cbd041c1ded804801 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:33:52 +0530 Subject: [PATCH 32/78] CHANGED REPO NAME & GRP ID OF NEXUS --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 914e69c14..6b6c79987 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline { NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-grp-repo" + NEXUS_REPO_ID = vprofile-release NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" } @@ -84,7 +85,7 @@ pipeline { nexusVersion: NEXUS_VERSION, protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, - groupId: pom.groupId, + groupId: NEXUS_REPO_ID, version: ARTVERSION, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, From dc626f94cef2f7e7af354281c804e275bfd1ae8c Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:35:01 +0530 Subject: [PATCH 33/78] GRP ID in doueble quotes in vars --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b6c79987..15df55893 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-grp-repo" - NEXUS_REPO_ID = vprofile-release + NEXUS_REPO_ID = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" } From cc260fe6dfa208ae60f2dedba704cd777da43f6e Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:45:55 +0530 Subject: [PATCH 34/78] Updated with integration test --- Jenkinsfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 15df55893..43d8b0c5a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { stage('BUILD'){ steps { - sh 'mvn package' + sh 'mvn clean install -DskipTests' } post { success { @@ -30,11 +30,17 @@ pipeline { } } - stage('TEST'){ + stage('UNIT TEST'){ steps { sh 'mvn test' } } + + stage('INTEGRATION TEST'){ + steps { + sh 'mvn verify -DskipUnitTests' + } + } stage ('CODE ANALYSIS WITH CHECKSTYLE'){ steps { @@ -85,7 +91,7 @@ pipeline { nexusVersion: NEXUS_VERSION, protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, - groupId: NEXUS_REPO_ID, + groupId: pom.groupId, version: ARTVERSION, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, From 67e3a44246b4bf8994b502255c4918ccdb532093 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 12:48:07 +0530 Subject: [PATCH 35/78] FIXED Nexus repo name --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 43d8b0c5a..be7508be5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { NEXUS_VERSION = "nexus3" NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-grp-repo" + NEXUS_REPOSITORY = "vprofile-release" NEXUS_REPO_ID = "vprofile-release" NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" From 8be69d948acefa98f06c5c3b4a4f1c90dd577071 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Thu, 23 Jul 2020 13:50:03 +0530 Subject: [PATCH 36/78] Updated nexus groupid in Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index be7508be5..969d00c6e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { NEXUS_PROTOCOL = "http" NEXUS_URL = "172.31.40.209:8081" NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPO_ID = "vprofile-release" + NEXUS_REPOGRP_ID = "vprofile-grp-repo" NEXUS_CREDENTIAL_ID = "nexuslogin" ARTVERSION = "${env.BUILD_ID}" } @@ -91,7 +91,7 @@ pipeline { nexusVersion: NEXUS_VERSION, protocol: NEXUS_PROTOCOL, nexusUrl: NEXUS_URL, - groupId: pom.groupId, + groupId: NEXUS_REPOGRP_ID, version: ARTVERSION, repository: NEXUS_REPOSITORY, credentialsId: NEXUS_CREDENTIAL_ID, From 73bcc431483ee782405543ee7759bf18ca632760 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Sun, 13 Sep 2020 09:45:38 +0530 Subject: [PATCH 37/78] nexus group repo as variable --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fd523d4a..58062014f 100644 --- a/pom.xml +++ b/pom.xml @@ -158,7 +158,7 @@ - vprofile-grp-repo + ${NEXUS_GRP_REPO} http://${NEXUSIP}:${NEXUSPORT}/repository/${REPONAME}/ From b3f21f1cf42e7d7de509124b335f779a43b532d9 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Sun, 13 Sep 2020 10:02:55 +0530 Subject: [PATCH 38/78] settings.xml file written --- setings.xml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 setings.xml diff --git a/setings.xml b/setings.xml new file mode 100644 index 000000000..8eae90eb1 --- /dev/null +++ b/setings.xml @@ -0,0 +1,28 @@ + + + + + + ${SNAP-REPO} + ${NEXUS-USER} + ${NEXUS-PASS} + + + ${RELEASE-REPO} + ${NEXUS-USER} + ${NEXUS-PASS} + + + + + + ${CENTRAL-REPO} + ${CENTRAL-REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO} + * + + + + From 254e365c7e0452af43f232b677b88806331d8080 Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Sun, 13 Sep 2020 10:09:28 +0530 Subject: [PATCH 39/78] settings.xml file name changed --- setings.xml => settings.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setings.xml => settings.xml (100%) diff --git a/setings.xml b/settings.xml similarity index 100% rename from setings.xml rename to settings.xml From 7a5c524b741420cd942268b2e97b20d575b53fce Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Sun, 13 Sep 2020 10:12:30 +0530 Subject: [PATCH 40/78] NEXUS_GRP_REPO --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58062014f..8c2567bf6 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ ${NEXUS_GRP_REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${REPONAME}/ + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ From 375d17f3367220119b620a9bd189b8887a1d05ed Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Sun, 13 Sep 2020 10:17:20 +0530 Subject: [PATCH 41/78] / --- settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.xml b/settings.xml index 8eae90eb1..d8609a96f 100644 --- a/settings.xml +++ b/settings.xml @@ -20,7 +20,7 @@ ${CENTRAL-REPO} ${CENTRAL-REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ * From 64fa6e43e9492f3eac0ce2bb77ba81458b2bb945 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Sun, 13 Sep 2020 10:19:10 +0530 Subject: [PATCH 42/78] --- --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8c2567bf6..59ce3bed6 100644 --- a/pom.xml +++ b/pom.xml @@ -158,8 +158,8 @@ - ${NEXUS_GRP_REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ + ${NEXUS-GRP-REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ From 006723055c628ca0246cac16e5720f5eba67f42c Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Mon, 21 Sep 2020 21:01:26 +0530 Subject: [PATCH 43/78] testing central repo login --- settings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.xml b/settings.xml index d8609a96f..67445b8b5 100644 --- a/settings.xml +++ b/settings.xml @@ -13,6 +13,11 @@ ${RELEASE-REPO} ${NEXUS-USER} ${NEXUS-PASS} + + + {CENTRAL-REPO} + ${NEXUS-USER} + ${NEXUS-PASS} From 20c8765ce9633c6fc3e39ec8e4d2f79b84a70256 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Mon, 21 Sep 2020 21:05:10 +0530 Subject: [PATCH 44/78] test group repo login --- settings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.xml b/settings.xml index 67445b8b5..f7e76f040 100644 --- a/settings.xml +++ b/settings.xml @@ -19,6 +19,11 @@ ${NEXUS-USER} ${NEXUS-PASS} + + {NEXUS-GRP-REPO} + ${NEXUS-USER} + ${NEXUS-PASS} + From 153a8629707a9181c2c18059308a2b183e8833a5 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:29:47 +0530 Subject: [PATCH 45/78] test CENTRAL-REPO --- settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.xml b/settings.xml index f7e76f040..c074d93ae 100644 --- a/settings.xml +++ b/settings.xml @@ -30,7 +30,7 @@ ${CENTRAL-REPO} ${CENTRAL-REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ + http://${NEXUSIP}:${NEXUSPORT}/repository/${CENTRAL-REPO}/ * From 960ac08b592fb568b3cd1e514151cac4764a2544 Mon Sep 17 00:00:00 2001 From: devopshydclub <46835275+devopshydclub@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:33:40 +0530 Subject: [PATCH 46/78] revert with NEXUS-GRP-REPO --- settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.xml b/settings.xml index c074d93ae..f7e76f040 100644 --- a/settings.xml +++ b/settings.xml @@ -30,7 +30,7 @@ ${CENTRAL-REPO} ${CENTRAL-REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${CENTRAL-REPO}/ + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ * From 48da7615c7b15cd120659507604c0e0f632df4cf Mon Sep 17 00:00:00 2001 From: Imran Teli Date: Wed, 30 Sep 2020 11:25:39 +0530 Subject: [PATCH 47/78] scripts for ci servers --- userdata/jenkins-setup.sh | 8 +++ userdata/nexus-setup.sh | 35 +++++++++++ userdata/sonar-setup.sh | 118 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 userdata/jenkins-setup.sh create mode 100644 userdata/nexus-setup.sh create mode 100644 userdata/sonar-setup.sh diff --git a/userdata/jenkins-setup.sh b/userdata/jenkins-setup.sh new file mode 100644 index 000000000..b7533b747 --- /dev/null +++ b/userdata/jenkins-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +sudo apt update +sudo apt install openjdk-8-jdk -y +sudo apt install maven git wget unzip -y +wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - +sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' +sudo apt-get update +sudo apt-get install jenkins -y \ No newline at end of file diff --git a/userdata/nexus-setup.sh b/userdata/nexus-setup.sh new file mode 100644 index 000000000..7d1c712cc --- /dev/null +++ b/userdata/nexus-setup.sh @@ -0,0 +1,35 @@ +#!/bin/bash +yum install java-1.8.0-openjdk.x86_64 wget -y +mkdir -p /opt/nexus/ +mkdir -p /tmp/nexus/ +cd /tmp/nexus +NEXUSURL="https://download.sonatype.com/nexus/3/latest-unix.tar.gz" +wget $NEXUSURL -O nexus.tar.gz +EXTOUT=`tar xzvf nexus.tar.gz` +NEXUSDIR=`echo $EXTOUT | cut -d '/' -f1` +rm -rf /tmp/nexus/nexus.tar.gz +rsync -avzh /tmp/nexus/ /opt/nexus/ +useradd nexus +chown -R nexus.nexus /opt/nexus +cat <> /etc/systemd/system/nexus.service +[Unit] +Description=nexus service +After=network.target + +[Service] +Type=forking +LimitNOFILE=65536 +ExecStart=/opt/nexus/$NEXUSDIR/bin/nexus start +ExecStop=/opt/nexus/$NEXUSDIR/bin/nexus stop +User=nexus +Restart=on-abort + +[Install] +WantedBy=multi-user.target + +EOT + +echo 'run_as_user="nexus"' > /opt/nexus/$NEXUSDIR/bin/nexus.rc +systemctl daemon-reload +systemctl start nexus +systemctl enable nexus diff --git a/userdata/sonar-setup.sh b/userdata/sonar-setup.sh new file mode 100644 index 000000000..ac59d8e73 --- /dev/null +++ b/userdata/sonar-setup.sh @@ -0,0 +1,118 @@ +#!/bin/bash +cp /etc/sysctl.conf /root/sysctl.conf_backup +cat < /etc/sysctl.conf +vm.max_map_count=262144 +fs.file-max=65536 +ulimit -n 65536 +ulimit -u 4096 +EOT +cp /etc/security/limits.conf /root/sec_limit.conf_backup +cat < /etc/security/limits.conf +sonarqube - nofile 65536 +sonarqube - nproc 409 +EOT + +sudo apt-get update -y +sudo apt-get install openjdk-11-jdk -y +sudo update-alternatives --config java +java -version + +sudo apt update +wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - + +sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' +sudo apt install postgresql postgresql-contrib -y +#sudo -u postgres psql -c "SELECT version();" +sudo systemctl enable postgresql.service +sudo systemctl start postgresql.service +sudo echo "postgres:admin123" | chpasswd +runuser -l postgres -c "createuser sonar" +sudo -i -u postgres psql -c "ALTER USER sonar WITH ENCRYPTED PASSWORD 'admin123';" +sudo -i -u postgres psql -c "CREATE DATABASE sonarqube OWNER sonar;" +sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar;" +systemctl restart postgresql +#systemctl status -l postgresql +netstat -tulpena | grep postgres +sudo mkdir -p /sonarqube/ +cd /sonarqube/ +sudo curl -O https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.3.0.34182.zip +sudo apt-get install zip -y +sudo unzip -o sonarqube-8.3.0.34182.zip -d /opt/ +sudo mv /opt/sonarqube-8.3.0.34182/ /opt/sonarqube +sudo groupadd sonar +sudo useradd -c "SonarQube - User" -d /opt/sonarqube/ -g sonar sonar +sudo chown sonar:sonar /opt/sonarqube/ -R +cp /opt/sonarqube/conf/sonar.properties /root/sonar.properties_backup +cat < /opt/sonarqube/conf/sonar.properties +sonar.jdbc.username=sonar +sonar.jdbc.password=admin123 +sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube +sonar.web.host=0.0.0.0 +sonar.web.port=9000 +sonar.web.javaAdditionalOpts=-server +sonar.search.javaOpts=-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError +sonar.log.level=INFO +sonar.path.logs=logs +EOT + +cat < /etc/systemd/system/sonarqube.service +[Unit] +Description=SonarQube service +After=syslog.target network.target + +[Service] +Type=forking + +ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start +ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop + +User=sonar +Group=sonar +Restart=always + +LimitNOFILE=65536 +LimitNPROC=4096 + + +[Install] +WantedBy=multi-user.target +EOT + +systemctl daemon-reload +systemctl enable sonarqube.service +#systemctl start sonarqube.service +#systemctl status -l sonarqube.service +apt-get install nginx -y +rm -rf /etc/nginx/sites-enabled/default +rm -rf /etc/nginx/sites-available/default +cat < /etc/nginx/sites-available/sonarqube +server{ + listen 80; + server_name sonarqube.groophy.in; + + access_log /var/log/nginx/sonar.access.log; + error_log /var/log/nginx/sonar.error.log; + + proxy_buffers 16 64k; + proxy_buffer_size 128k; + + location / { + proxy_pass http://127.0.0.1:9000; + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_redirect off; + + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto http; + } +} +EOT +ln -s /etc/nginx/sites-available/sonarqube /etc/nginx/sites-enabled/sonarqube +systemctl enable nginx.service +#systemctl restart nginx.service +sudo ufw allow 80,9000,9001/tcp + +echo "System reboot in 30 sec" +sleep 30 +reboot From d4380568bcf2691677308f07727a986d534a85fe Mon Sep 17 00:00:00 2001 From: santonix Date: Tue, 10 Sep 2024 22:50:06 +0200 Subject: [PATCH 48/78] preparing cicd branch --- Docker-files/app/Dockerfile | 11 +++ Docker-files/app/multistage/Dockerfile | 13 +++ Docker-files/d.txt | 0 Docker-files/db/Dockerfile | 9 ++ Docker-files/db/db_backup.sql | 121 ++++++++++++++++++++++++ Docker-files/web/Dockerfile | 6 ++ Docker-files/web/nginvproapp.conf | 9 ++ Jenkinsfile => ProdPipeline/Jenkinsfile | 0 StagePipeline/Jenkinsfile | 121 ++++++++++++++++++++++++ 9 files changed, 290 insertions(+) create mode 100644 Docker-files/app/Dockerfile create mode 100644 Docker-files/app/multistage/Dockerfile create mode 100644 Docker-files/d.txt create mode 100644 Docker-files/db/Dockerfile create mode 100644 Docker-files/db/db_backup.sql create mode 100644 Docker-files/web/Dockerfile create mode 100644 Docker-files/web/nginvproapp.conf rename Jenkinsfile => ProdPipeline/Jenkinsfile (100%) create mode 100644 StagePipeline/Jenkinsfile diff --git a/Docker-files/app/Dockerfile b/Docker-files/app/Dockerfile new file mode 100644 index 000000000..22b8aa8b1 --- /dev/null +++ b/Docker-files/app/Dockerfile @@ -0,0 +1,11 @@ +FROM tomcat:8-jre11 +LABEL "Project"="Vprofile" +LABEL "Author"="Imran" + +RUN rm -rf /usr/local/tomcat/webapps/* +COPY target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war + +EXPOSE 8080 +CMD ["catalina.sh", "run"] +WORKDIR /usr/local/tomcat/ +VOLUME /usr/local/tomcat/webapps \ No newline at end of file diff --git a/Docker-files/app/multistage/Dockerfile b/Docker-files/app/multistage/Dockerfile new file mode 100644 index 000000000..4163bed27 --- /dev/null +++ b/Docker-files/app/multistage/Dockerfile @@ -0,0 +1,13 @@ +FROM openjdk:11 AS BUILD_IMAGE +RUN apt update && apt install maven -y +RUN git clone https://github.com/devopshydclub/vprofile-project.git +RUN cd vprofile-project && git checkout docker && mvn install + +FROM tomcat:9-jre11 + +RUN rm -rf /usr/local/tomcat/webapps/* + +COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war + +EXPOSE 8080 +CMD ["catalina.sh", "run"] diff --git a/Docker-files/d.txt b/Docker-files/d.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Docker-files/db/Dockerfile b/Docker-files/db/Dockerfile new file mode 100644 index 000000000..120a5b8cd --- /dev/null +++ b/Docker-files/db/Dockerfile @@ -0,0 +1,9 @@ +FROM mysql:8.0.33 +LABEL "Project"="Vprofile" +LABEL "Author"="Imran" + +ENV MYSQL_ROOT_PASSWORD="vprodbpass" +ENV MYSQL_DATABASE="accounts" + + +ADD db_backup.sql docker-entrypoint-initdb.d/db_backup.sql diff --git a/Docker-files/db/db_backup.sql b/Docker-files/db/db_backup.sql new file mode 100644 index 000000000..bdb779d23 --- /dev/null +++ b/Docker-files/db/db_backup.sql @@ -0,0 +1,121 @@ +-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) +-- +-- Host: localhost Database: accounts +-- ------------------------------------------------------ +-- Server version 5.7.18-0ubuntu0.16.10.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `role` +-- + +DROP TABLE IF EXISTS `role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `role` +-- + +LOCK TABLES `role` WRITE; +/*!40000 ALTER TABLE `role` DISABLE KEYS */; +INSERT INTO `role` VALUES (1,'ROLE_USER'); +/*!40000 ALTER TABLE `role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) DEFAULT NULL, + `userEmail` varchar(255) DEFAULT NULL, + `profileImg` varchar(255) DEFAULT NULL, + `profileImgPath` varchar(255) DEFAULT NULL, + `dateOfBirth` varchar(255) DEFAULT NULL, + `fatherName` varchar(255) DEFAULT NULL, + `motherName` varchar(255) DEFAULT NULL, + `gender` varchar(255) DEFAULT NULL, + `maritalStatus` varchar(255) DEFAULT NULL, + `permanentAddress` varchar(255) DEFAULT NULL, + `tempAddress` varchar(255) DEFAULT NULL, + `primaryOccupation` varchar(255) DEFAULT NULL, + `secondaryOccupation` varchar(255) DEFAULT NULL, + `skills` varchar(255) DEFAULT NULL, + `phoneNumber` varchar(255) DEFAULT NULL, + `secondaryPhoneNumber` varchar(255) DEFAULT NULL, + `nationality` varchar(255) DEFAULT NULL, + `language` varchar(255) DEFAULT NULL, + `workingExperience` varchar(255) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user` +-- + +LOCK TABLES `user` WRITE; +/*!40000 ALTER TABLE `user` DISABLE KEYS */; +INSERT INTO `user` VALUES (7,'admin_vp','admin@visualpathit.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$0a7VdTr4rfCQqtsvpng6GuJnzUmQ7gZiHXgzGPgm5hkRa3avXgBLK'),(8,'WahidKhan','wahid.khan74@gmail.com',NULL,NULL,'28/03/1994','M Khan','R Khan','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','8888888888','8888888888','Indian','english','2 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6JAW'),(9,'Gayatri','gayatri@gmail.com',NULL,NULL,'20/06/1993','K','L','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','9999999999','9999999999','India','english','5','$2a$11$gwvsvUrFU.YirMM1Yb7NweFudLUM91AzH5BDFnhkNzfzpjG.FplYO'),(10,'WahidKhan2','wahid.khan741@gmail.com',NULL,NULL,'28/03/1994','M Khan','R Khan','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','7777777777','777777777','India','english','7','$2a$11$6oZEgfGGQAH23EaXLVZ2WOSKxcEJFnBSw2N2aghab0s2kcxSQwjhC'),(11,'KiranKumar','kiran@gmail.com',NULL,NULL,'8/12/1993','K K','RK','male','unMarried','California','James Street','Software Engineer','Software Engineer','Java HTML CSS ','1010101010','1010101010','India','english','10','$2a$11$EXwpna1MlFFlKW5ut1iVi.AoeIulkPPmcOHFO8pOoQt1IYU9COU0m'),(12,'Saikumar','sai@gmail.com',NULL,NULL,'20/06/1993','Sai RK','Sai AK','male','unMarried','California','US','Software Engineer','Software Engineer','Java HTML CSS AWS','8888888111','8888888111','India','english','8','$2a$11$pzWNzzR.HUkHzz2zhAgqOeCl0WaTgY33NxxJ7n0l.rnEqjB9JO7vy'),(13,'RamSai','ram@gmail.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$6BSmYPrT8I8b9yHmx.uTRu/QxnQM2vhZYQa8mR33aReWA4WFihyGK'); +/*!40000 ALTER TABLE `user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_role` +-- + +DROP TABLE IF EXISTS `user_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_role` ( + `user_id` int(11) NOT NULL, + `role_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`role_id`), + KEY `fk_user_role_roleid_idx` (`role_id`), + CONSTRAINT `fk_user_role_roleid` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_user_role_userid` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_role` +-- + +LOCK TABLES `user_role` WRITE; +/*!40000 ALTER TABLE `user_role` DISABLE KEYS */; +INSERT INTO `user_role` VALUES (4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1); +/*!40000 ALTER TABLE `user_role` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-12-07 16:32:31 diff --git a/Docker-files/web/Dockerfile b/Docker-files/web/Dockerfile new file mode 100644 index 000000000..99d468509 --- /dev/null +++ b/Docker-files/web/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx +LABEL "Project"="Vprofile" +LABEL "Author"="Imran" + +RUN rm -rf /etc/nginx/conf.d/default.conf +COPY nginvproapp.conf /etc/nginx/conf.d/vproapp.conf \ No newline at end of file diff --git a/Docker-files/web/nginvproapp.conf b/Docker-files/web/nginvproapp.conf new file mode 100644 index 000000000..ab3a503e4 --- /dev/null +++ b/Docker-files/web/nginvproapp.conf @@ -0,0 +1,9 @@ +upstream vproapp { + server vproapp:8080; +} +server { + listen 80; +location / { + proxy_pass http://vproapp; +} +} \ No newline at end of file diff --git a/Jenkinsfile b/ProdPipeline/Jenkinsfile similarity index 100% rename from Jenkinsfile rename to ProdPipeline/Jenkinsfile diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile new file mode 100644 index 000000000..969d00c6e --- /dev/null +++ b/StagePipeline/Jenkinsfile @@ -0,0 +1,121 @@ +pipeline { + + agent any +/* + tools { + maven "maven3" + } +*/ + environment { + NEXUS_VERSION = "nexus3" + NEXUS_PROTOCOL = "http" + NEXUS_URL = "172.31.40.209:8081" + NEXUS_REPOSITORY = "vprofile-release" + NEXUS_REPOGRP_ID = "vprofile-grp-repo" + NEXUS_CREDENTIAL_ID = "nexuslogin" + ARTVERSION = "${env.BUILD_ID}" + } + + stages{ + + stage('BUILD'){ + steps { + sh 'mvn clean install -DskipTests' + } + post { + success { + echo 'Now Archiving...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST'){ + steps { + sh 'mvn test' + } + } + + stage('INTEGRATION TEST'){ + steps { + sh 'mvn verify -DskipUnitTests' + } + } + + stage ('CODE ANALYSIS WITH CHECKSTYLE'){ + steps { + sh 'mvn checkstyle:checkstyle' + } + post { + success { + echo 'Generated Analysis Result' + } + } + } + + stage('CODE ANALYSIS with SONARQUBE') { + + environment { + scannerHome = tool 'sonarscanner4' + } + + steps { + withSonarQubeEnv('sonar-pro') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile-repo \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + + timeout(time: 10, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + } + } + + stage("Publish to Nexus Repository Manager") { + steps { + script { + pom = readMavenPom file: "pom.xml"; + filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); + echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" + artifactPath = filesByGlob[0].path; + artifactExists = fileExists artifactPath; + if(artifactExists) { + echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; + nexusArtifactUploader( + nexusVersion: NEXUS_VERSION, + protocol: NEXUS_PROTOCOL, + nexusUrl: NEXUS_URL, + groupId: NEXUS_REPOGRP_ID, + version: ARTVERSION, + repository: NEXUS_REPOSITORY, + credentialsId: NEXUS_CREDENTIAL_ID, + artifacts: [ + [artifactId: pom.artifactId, + classifier: '', + file: artifactPath, + type: pom.packaging], + [artifactId: pom.artifactId, + classifier: '', + file: "pom.xml", + type: "pom"] + ] + ); + } + else { + error "*** File: ${artifactPath}, could not be found"; + } + } + } + } + + + } + + +} From 791e0a18de05f93bc2710c926b2597609741caff Mon Sep 17 00:00:00 2001 From: santonix Date: Tue, 10 Sep 2024 23:51:30 +0200 Subject: [PATCH 49/78] docker build and publish to ecr --- ProdPipeline/Jenkinsfile | 175 +++++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 82 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 969d00c6e..fe9d3c56f 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -1,121 +1,132 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] pipeline { - - agent any -/* - tools { - maven "maven3" + agent any + tools { + maven "MAVEN3" + jdk "jdk17" } -*/ + environment { - NEXUS_VERSION = "nexus3" - NEXUS_PROTOCOL = "http" - NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPOGRP_ID = "vprofile-grp-repo" - NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "${env.BUILD_ID}" + SNAP_REPO = 'vprofile-snapshot' + NEXUS_USER = 'admin' + NEXUS_PASS = 'walter' + RELEASE_REPO = 'vprofile-release' + CENTRAL_REPO = 'vpro-maven-central' + NEXUSIP = '34.134.153.215' + NEXUSPORT = '8081' + NEXUS_GRP_REPO = 'vpro-maven-group' + NEXUS_LOGIN = 'nexuslogin' + SONARSERVER = 'sonar-server' + SONARSCANNER = 'sonar-scanner' + registryCredential = 'ecr:us-east-2:aws-cred-id' + appRegistry = '163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg' + vprofileRegistry = "163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg" } - - stages{ - - stage('BUILD'){ + + stages { + stage('Build'){ steps { - sh 'mvn clean install -DskipTests' + sh 'mvn -s settings.xml -DskipTests install' } post { success { - echo 'Now Archiving...' - archiveArtifacts artifacts: '**/target/*.war' + echo "Now Archiving." + archiveArtifacts artifacts: '**/*.war' } } } - stage('UNIT TEST'){ + stage('Test'){ steps { - sh 'mvn test' + sh 'mvn -s settings.xml test' } - } - stage('INTEGRATION TEST'){ - steps { - sh 'mvn verify -DskipUnitTests' - } } - - stage ('CODE ANALYSIS WITH CHECKSTYLE'){ + + stage('Checkstyle Analysis'){ steps { - sh 'mvn checkstyle:checkstyle' - } - post { - success { - echo 'Generated Analysis Result' - } + sh 'mvn -s settings.xml checkstyle:checkstyle' } } - stage('CODE ANALYSIS with SONARQUBE') { - - environment { - scannerHome = tool 'sonarscanner4' - } - - steps { - withSonarQubeEnv('sonar-pro') { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile-repo \ + stage('Sonar Analysis') { + environment { + scannerHome = tool "${SONARSCANNER}" + } + steps { + withSonarQubeEnv("${SONARSERVER}") { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ -Dsonar.projectVersion=1.0 \ -Dsonar.sources=src/ \ -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ -Dsonar.junit.reportsPath=target/surefire-reports/ \ -Dsonar.jacoco.reportsPath=target/jacoco.exec \ -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } } + } - timeout(time: 10, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails + // true = set pipeline to UNSTABLE, false = don't + waitForQualityGate abortPipeline: true + } } - } } - stage("Publish to Nexus Repository Manager") { + stage("UploadArtifact"){ + steps{ + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: "${NEXUSIP}:${NEXUSPORT}", + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: "${RELEASE_REPO}", + credentialsId: "${NEXUS_LOGIN}", + artifacts: [ + [artifactId: 'vproapp', + classifier: '', + file: 'target/vprofile-v2.war', + type: 'war'] + ] + ) + } + } + + stage('Build App Image') { steps { script { - pom = readMavenPom file: "pom.xml"; - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - artifactPath = filesByGlob[0].path; - artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; - nexusArtifactUploader( - nexusVersion: NEXUS_VERSION, - protocol: NEXUS_PROTOCOL, - nexusUrl: NEXUS_URL, - groupId: NEXUS_REPOGRP_ID, - version: ARTVERSION, - repository: NEXUS_REPOSITORY, - credentialsId: NEXUS_CREDENTIAL_ID, - artifacts: [ - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging], - [artifactId: pom.artifactId, - classifier: '', - file: "pom.xml", - type: "pom"] - ] - ); - } - else { - error "*** File: ${artifactPath}, could not be found"; - } + dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/") } } } + + stage('Upload App Image') { + steps{ + script { + docker.withRegistry( vprofileRegistry, registryCredential ) { + dockerImage.push("$BUILD_NUMBER") + dockerImage.push('latest') + } + } + } + } } - - -} + post { + always { + echo 'Slack Notifications.' + slackSend channel: '#jenkinscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + } + } +} \ No newline at end of file From a6349ee44d92b4342513fb2729fb8547d9d2c931 Mon Sep 17 00:00:00 2001 From: santonix Date: Tue, 10 Sep 2024 23:57:36 +0200 Subject: [PATCH 50/78] fix maven in staging jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index fe9d3c56f..36456859c 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -5,7 +5,7 @@ def COLOR_MAP = [ pipeline { agent any tools { - maven "MAVEN3" + maven "maven3" jdk "jdk17" } From 2aaa63809857ecdb9e53c894fb2c58f283f0fdf8 Mon Sep 17 00:00:00 2001 From: santonix Date: Wed, 11 Sep 2024 00:11:00 +0200 Subject: [PATCH 51/78] modify the java version --- StagePipeline/Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile index 969d00c6e..33bfff42e 100644 --- a/StagePipeline/Jenkinsfile +++ b/StagePipeline/Jenkinsfile @@ -4,6 +4,9 @@ pipeline { /* tools { maven "maven3" + jdk "jdk8" + + } */ environment { From 485db7ed2704b82da4aff2bbd3fb1b1d5c15b6fb Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:10:58 +0200 Subject: [PATCH 52/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 36456859c..4ad77bad4 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -14,10 +14,10 @@ pipeline { NEXUS_USER = 'admin' NEXUS_PASS = 'walter' RELEASE_REPO = 'vprofile-release' - CENTRAL_REPO = 'vpro-maven-central' + CENTRAL_REPO = 'vprofile-release' NEXUSIP = '34.134.153.215' NEXUSPORT = '8081' - NEXUS_GRP_REPO = 'vpro-maven-group' + NEXUS_GRP_REPO = 'vprofile-group' NEXUS_LOGIN = 'nexuslogin' SONARSERVER = 'sonar-server' SONARSCANNER = 'sonar-scanner' @@ -129,4 +129,4 @@ pipeline { message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" } } -} \ No newline at end of file +} From 679835c65dbf7aa30e43a3a759e42d30c14ffc3b Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:15:22 +0200 Subject: [PATCH 53/78] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 59ce3bed6..c34640552 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ ${NEXUS-GRP-REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ From 48749a050676ad1cd45a4e13c0d1bab10cf7ca02 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:21:51 +0200 Subject: [PATCH 54/78] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c34640552..8c2567bf6 100644 --- a/pom.xml +++ b/pom.xml @@ -158,7 +158,7 @@ - ${NEXUS-GRP-REPO} + ${NEXUS_GRP_REPO} http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ From 000e08224aaa2241c814af622022f71a9ec83619 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:27:51 +0200 Subject: [PATCH 55/78] Update settings.xml --- settings.xml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/settings.xml b/settings.xml index f7e76f040..2b4b4a29e 100644 --- a/settings.xml +++ b/settings.xml @@ -5,32 +5,32 @@ - ${SNAP-REPO} - ${NEXUS-USER} - ${NEXUS-PASS} + ${SNAP_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} - ${RELEASE-REPO} - ${NEXUS-USER} - ${NEXUS-PASS} + ${RELEASE_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} - {CENTRAL-REPO} - ${NEXUS-USER} - ${NEXUS-PASS} + {CENTRAL_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} - {NEXUS-GRP-REPO} - ${NEXUS-USER} - ${NEXUS-PASS} + {NEXUS_GRP_REPO} + ${NEXUS_USER} + ${NEXUS_PASS} - ${CENTRAL-REPO} - ${CENTRAL-REPO} - http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/ + ${CENTRAL_REPO} + ${CENTRAL_REPO} + http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS_GRP_REPO}/ * From 9e57218218bf03ab5f1c8dc98db061cdbf1f7f3e Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:42:08 +0200 Subject: [PATCH 56/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 4ad77bad4..eb790fbe9 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -11,13 +11,13 @@ pipeline { environment { SNAP_REPO = 'vprofile-snapshot' - NEXUS_USER = 'admin' - NEXUS_PASS = 'walter' - RELEASE_REPO = 'vprofile-release' - CENTRAL_REPO = 'vprofile-release' - NEXUSIP = '34.134.153.215' - NEXUSPORT = '8081' - NEXUS_GRP_REPO = 'vprofile-group' + NEXUS_USER = 'admin' + NEXUS_PASS = 'walter' + RELEASE_REPO = 'vprofile-release' + CENTRAL_REPO = 'vprofile-release' + NEXUSIP = '34.134.153.215' + NEXUSPORT = '8081' + NEXUS_GRP_REPO = 'vprofile-group' NEXUS_LOGIN = 'nexuslogin' SONARSERVER = 'sonar-server' SONARSCANNER = 'sonar-scanner' From a21100d7ec599838584312e9e58aa503bf11d5d6 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:01:34 +0200 Subject: [PATCH 57/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index eb790fbe9..351123c16 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -29,7 +29,7 @@ pipeline { stages { stage('Build'){ steps { - sh 'mvn -s settings.xml -DskipTests install' + sh 'mvn -s settings.xml -DskipTests clean install' } post { success { From ecd70a5ebd53ef9433cec1bdac7f8ee3bac7c183 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:10:39 +0200 Subject: [PATCH 58/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 351123c16..61e913ca6 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk17" + jdk "jdk8" } environment { From 5514f928fccc749b7f75ebfa643020356e9bf465 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:29:36 +0200 Subject: [PATCH 59/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 61e913ca6..351123c16 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk8" + jdk "jdk17" } environment { From a624636a541d2fe63f1467fcadb01a627c192e1b Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:33:23 +0200 Subject: [PATCH 60/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 351123c16..f3db063ad 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk17" + jdk "jdk11" } environment { From 37c736ddc17a79997c1ac861430e48716c7ff7ff Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:39:01 +0200 Subject: [PATCH 61/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index f3db063ad..b4c10de6f 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -5,8 +5,8 @@ def COLOR_MAP = [ pipeline { agent any tools { - maven "maven3" - jdk "jdk11" + maven 'maven3' + jdk 'jdk11' } environment { From e4aa783b758bfc9bed9bc99f8c4c1cd59727708a Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:43:13 +0200 Subject: [PATCH 62/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index b4c10de6f..ff5ed8148 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven 'maven3' - jdk 'jdk11' + java 'jdk11' } environment { From d4fbec9891f6552d830150f2c2c86d4ba448ed75 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:46:25 +0200 Subject: [PATCH 63/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index ff5ed8148..b4c10de6f 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven 'maven3' - java 'jdk11' + jdk 'jdk11' } environment { From bec23b668206ec02380377792b1473eadf8c73f4 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:48:37 +0200 Subject: [PATCH 64/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index b4c10de6f..063373d82 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -5,8 +5,8 @@ def COLOR_MAP = [ pipeline { agent any tools { - maven 'maven3' - jdk 'jdk11' + maven "maven3" + jdk "jdk11" } environment { From 7f5df3b678efc872acc432848028a446804af2c8 Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:50:46 +0200 Subject: [PATCH 65/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 063373d82..8b6a36ac2 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk11" + jdk "jdk8" } environment { From 6d74eed7e42c8d9cdfc638c41d047f1a17647b0c Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:42:52 +0200 Subject: [PATCH 66/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 8b6a36ac2..f720a9327 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk8" + jdk "jdk17" } environment { From a0b10ea1363512efdf66608f1b83dccf31626b8e Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:58:36 +0200 Subject: [PATCH 67/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index f720a9327..8b6a36ac2 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk17" + jdk "jdk8" } environment { From d51dc708995a36229b2331259da8b86e38e5ea1b Mon Sep 17 00:00:00 2001 From: santonix <121695750+santonix@users.noreply.github.com> Date: Wed, 11 Sep 2024 21:17:24 +0200 Subject: [PATCH 68/78] Update Jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 8b6a36ac2..f720a9327 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { agent any tools { maven "maven3" - jdk "jdk8" + jdk "jdk17" } environment { From e840c00250209ce99ebb353d26ec45106ae0789f Mon Sep 17 00:00:00 2001 From: santonix Date: Wed, 11 Sep 2024 21:24:28 +0200 Subject: [PATCH 69/78] set maven compiler version to 17 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 59ce3bed6..21850d684 100644 --- a/pom.xml +++ b/pom.xml @@ -18,8 +18,8 @@ 1.2 4.10 1.1.3 - 1.8 - 1.8 + 17 + 17 From d01a150f84685960d27ebaeef765de277a8d0317 Mon Sep 17 00:00:00 2001 From: santonix Date: Wed, 11 Sep 2024 21:43:52 +0200 Subject: [PATCH 70/78] modify the pom.xml --- pom.xml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88f16ea47..c61af061a 100644 --- a/pom.xml +++ b/pom.xml @@ -136,7 +136,7 @@ org.jacoco jacoco-maven-plugin - 0.7.2.201409121644 + 0.8.8 jacoco-initialize @@ -154,6 +154,21 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + From e20d7cfa49b5c6758ffc3320e3846a64f49f024e Mon Sep 17 00:00:00 2001 From: santonix Date: Wed, 11 Sep 2024 22:22:14 +0200 Subject: [PATCH 71/78] configure jenkifile with ecr config --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index f720a9327..f2b126b88 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { SONARSCANNER = 'sonar-scanner' registryCredential = 'ecr:us-east-2:aws-cred-id' appRegistry = '163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg' - vprofileRegistry = "163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg" + vprofileRegistry = "https://163447728448.dkr.ecr.us-east-2.amazonaws.com" } stages { From da51a51d40302f95970650fe93910b4011b589fd Mon Sep 17 00:00:00 2001 From: santonix Date: Wed, 11 Sep 2024 22:30:54 +0200 Subject: [PATCH 72/78] update the jenkinsfile --- ProdPipeline/Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index f2b126b88..5fa62b6bf 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -124,9 +124,17 @@ pipeline { post { always { echo 'Slack Notifications.' - slackSend channel: '#jenkinscicd', + slackSend ( + channel: '#jenkinscicd', color: COLOR_MAP[currentBuild.currentResult], message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + ) + + mail ( + to: 'jofranco1203@gmail.com', + subject: "Build ${env.JOB_NAME} - #${env.BUILD_NUMBER} ${currentBuild.currentResult}", + body: "Build details: ${env.BUILD_URL}" + ) } } } From c337e0140bdfce87163dd7455aef2efee3e22c09 Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 19:45:51 +0200 Subject: [PATCH 73/78] added jenkinsfile in stagepipeline --- StagePipeline/Jenkinsfile | 180 +++++++++++++++++++++----------------- 1 file changed, 98 insertions(+), 82 deletions(-) diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile index 33bfff42e..5fa62b6bf 100644 --- a/StagePipeline/Jenkinsfile +++ b/StagePipeline/Jenkinsfile @@ -1,124 +1,140 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] pipeline { - - agent any -/* - tools { + agent any + tools { maven "maven3" - jdk "jdk8" - - + jdk "jdk17" } -*/ + environment { - NEXUS_VERSION = "nexus3" - NEXUS_PROTOCOL = "http" - NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPOGRP_ID = "vprofile-grp-repo" - NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "${env.BUILD_ID}" + SNAP_REPO = 'vprofile-snapshot' + NEXUS_USER = 'admin' + NEXUS_PASS = 'walter' + RELEASE_REPO = 'vprofile-release' + CENTRAL_REPO = 'vprofile-release' + NEXUSIP = '34.134.153.215' + NEXUSPORT = '8081' + NEXUS_GRP_REPO = 'vprofile-group' + NEXUS_LOGIN = 'nexuslogin' + SONARSERVER = 'sonar-server' + SONARSCANNER = 'sonar-scanner' + registryCredential = 'ecr:us-east-2:aws-cred-id' + appRegistry = '163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg' + vprofileRegistry = "https://163447728448.dkr.ecr.us-east-2.amazonaws.com" } - - stages{ - - stage('BUILD'){ + + stages { + stage('Build'){ steps { - sh 'mvn clean install -DskipTests' + sh 'mvn -s settings.xml -DskipTests clean install' } post { success { - echo 'Now Archiving...' - archiveArtifacts artifacts: '**/target/*.war' + echo "Now Archiving." + archiveArtifacts artifacts: '**/*.war' } } } - stage('UNIT TEST'){ + stage('Test'){ steps { - sh 'mvn test' + sh 'mvn -s settings.xml test' } - } - stage('INTEGRATION TEST'){ - steps { - sh 'mvn verify -DskipUnitTests' - } } - - stage ('CODE ANALYSIS WITH CHECKSTYLE'){ + + stage('Checkstyle Analysis'){ steps { - sh 'mvn checkstyle:checkstyle' - } - post { - success { - echo 'Generated Analysis Result' - } + sh 'mvn -s settings.xml checkstyle:checkstyle' } } - stage('CODE ANALYSIS with SONARQUBE') { - - environment { - scannerHome = tool 'sonarscanner4' - } - - steps { - withSonarQubeEnv('sonar-pro') { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile-repo \ + stage('Sonar Analysis') { + environment { + scannerHome = tool "${SONARSCANNER}" + } + steps { + withSonarQubeEnv("${SONARSERVER}") { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ -Dsonar.projectVersion=1.0 \ -Dsonar.sources=src/ \ -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ -Dsonar.junit.reportsPath=target/surefire-reports/ \ -Dsonar.jacoco.reportsPath=target/jacoco.exec \ -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } } + } - timeout(time: 10, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails + // true = set pipeline to UNSTABLE, false = don't + waitForQualityGate abortPipeline: true + } + } + } + + stage("UploadArtifact"){ + steps{ + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: "${NEXUSIP}:${NEXUSPORT}", + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: "${RELEASE_REPO}", + credentialsId: "${NEXUS_LOGIN}", + artifacts: [ + [artifactId: 'vproapp', + classifier: '', + file: 'target/vprofile-v2.war', + type: 'war'] + ] + ) } - } } - stage("Publish to Nexus Repository Manager") { + stage('Build App Image') { steps { script { - pom = readMavenPom file: "pom.xml"; - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - artifactPath = filesByGlob[0].path; - artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; - nexusArtifactUploader( - nexusVersion: NEXUS_VERSION, - protocol: NEXUS_PROTOCOL, - nexusUrl: NEXUS_URL, - groupId: NEXUS_REPOGRP_ID, - version: ARTVERSION, - repository: NEXUS_REPOSITORY, - credentialsId: NEXUS_CREDENTIAL_ID, - artifacts: [ - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging], - [artifactId: pom.artifactId, - classifier: '', - file: "pom.xml", - type: "pom"] - ] - ); - } - else { - error "*** File: ${artifactPath}, could not be found"; - } + dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/") } } } + + stage('Upload App Image') { + steps{ + script { + docker.withRegistry( vprofileRegistry, registryCredential ) { + dockerImage.push("$BUILD_NUMBER") + dockerImage.push('latest') + } + } + } + } } + post { + always { + echo 'Slack Notifications.' + slackSend ( + channel: '#jenkinscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + ) - + mail ( + to: 'jofranco1203@gmail.com', + subject: "Build ${env.JOB_NAME} - #${env.BUILD_NUMBER} ${currentBuild.currentResult}", + body: "Build details: ${env.BUILD_URL}" + ) + } + } } From 5dadfbac70808500131e7ed1870a317559468334 Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 21:12:49 +0200 Subject: [PATCH 74/78] deploy to ecs --- ProdPipeline/Jenkinsfile | 140 -------------------------------------- StagePipeline/Jenkinsfile | 12 +++- 2 files changed, 11 insertions(+), 141 deletions(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index 5fa62b6bf..e69de29bb 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -1,140 +0,0 @@ -def COLOR_MAP = [ - 'SUCCESS': 'good', - 'FAILURE': 'danger', -] -pipeline { - agent any - tools { - maven "maven3" - jdk "jdk17" - } - - environment { - SNAP_REPO = 'vprofile-snapshot' - NEXUS_USER = 'admin' - NEXUS_PASS = 'walter' - RELEASE_REPO = 'vprofile-release' - CENTRAL_REPO = 'vprofile-release' - NEXUSIP = '34.134.153.215' - NEXUSPORT = '8081' - NEXUS_GRP_REPO = 'vprofile-group' - NEXUS_LOGIN = 'nexuslogin' - SONARSERVER = 'sonar-server' - SONARSCANNER = 'sonar-scanner' - registryCredential = 'ecr:us-east-2:aws-cred-id' - appRegistry = '163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg' - vprofileRegistry = "https://163447728448.dkr.ecr.us-east-2.amazonaws.com" - } - - stages { - stage('Build'){ - steps { - sh 'mvn -s settings.xml -DskipTests clean install' - } - post { - success { - echo "Now Archiving." - archiveArtifacts artifacts: '**/*.war' - } - } - } - - stage('Test'){ - steps { - sh 'mvn -s settings.xml test' - } - - } - - stage('Checkstyle Analysis'){ - steps { - sh 'mvn -s settings.xml checkstyle:checkstyle' - } - } - - stage('Sonar Analysis') { - environment { - scannerHome = tool "${SONARSCANNER}" - } - steps { - withSonarQubeEnv("${SONARSERVER}") { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile \ - -Dsonar.projectVersion=1.0 \ - -Dsonar.sources=src/ \ - -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ - -Dsonar.junit.reportsPath=target/surefire-reports/ \ - -Dsonar.jacoco.reportsPath=target/jacoco.exec \ - -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' - } - } - } - - stage("Quality Gate") { - steps { - timeout(time: 1, unit: 'HOURS') { - // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails - // true = set pipeline to UNSTABLE, false = don't - waitForQualityGate abortPipeline: true - } - } - } - - stage("UploadArtifact"){ - steps{ - nexusArtifactUploader( - nexusVersion: 'nexus3', - protocol: 'http', - nexusUrl: "${NEXUSIP}:${NEXUSPORT}", - groupId: 'QA', - version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", - repository: "${RELEASE_REPO}", - credentialsId: "${NEXUS_LOGIN}", - artifacts: [ - [artifactId: 'vproapp', - classifier: '', - file: 'target/vprofile-v2.war', - type: 'war'] - ] - ) - } - } - - stage('Build App Image') { - steps { - script { - dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/") - } - } - } - - stage('Upload App Image') { - steps{ - script { - docker.withRegistry( vprofileRegistry, registryCredential ) { - dockerImage.push("$BUILD_NUMBER") - dockerImage.push('latest') - } - } - } - } - - - } - post { - always { - echo 'Slack Notifications.' - slackSend ( - channel: '#jenkinscicd', - color: COLOR_MAP[currentBuild.currentResult], - message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" - ) - - mail ( - to: 'jofranco1203@gmail.com', - subject: "Build ${env.JOB_NAME} - #${env.BUILD_NUMBER} ${currentBuild.currentResult}", - body: "Build details: ${env.BUILD_URL}" - ) - } - } -} diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile index 5fa62b6bf..d13b68701 100644 --- a/StagePipeline/Jenkinsfile +++ b/StagePipeline/Jenkinsfile @@ -23,7 +23,9 @@ pipeline { SONARSCANNER = 'sonar-scanner' registryCredential = 'ecr:us-east-2:aws-cred-id' appRegistry = '163447728448.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg' - vprofileRegistry = "https://163447728448.dkr.ecr.us-east-2.amazonaws.com" + vprofileRegistry = "https://163447728448.dkr.ecr.us-east-2.amazonaws.com" + cluster = "bonny-vprostaging" + service = "vproappstagesvc" } stages { @@ -119,6 +121,14 @@ pipeline { } } + tage('Deploy to ECS staging') { + steps { + withAWS(credentials: 'aws-cred-id', region: 'us-east-2') { + sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment' + } + } + } + } post { From 91a1310728bbbacef67e97e15f839b1dd3b08e06 Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 21:14:24 +0200 Subject: [PATCH 75/78] jenkinsfile correction --- StagePipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StagePipeline/Jenkinsfile b/StagePipeline/Jenkinsfile index d13b68701..cfca5d93e 100644 --- a/StagePipeline/Jenkinsfile +++ b/StagePipeline/Jenkinsfile @@ -121,7 +121,7 @@ pipeline { } } - tage('Deploy to ECS staging') { + stage('Deploy to ECS staging') { steps { withAWS(credentials: 'aws-cred-id', region: 'us-east-2') { sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment' From 0ff24d1110b0aaa40eb9fb74131673099d5cc37a Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 21:39:13 +0200 Subject: [PATCH 76/78] defined jenkinsfile for prod --- ProdPipeline/Jenkinsfile | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index e69de29bb..cfc2a556b 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -0,0 +1,41 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] + +pipeline { + agent any + + environment { + cluster = "vproprod" + service = "vproprodsvc" + } + + stages { + stage('Deploy to Prod ecs') { + steps { + withAWS(credentials: 'aws-cred-id', region: 'us-east-2') { + sh 'aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment' + } + } + } + + } + + post { + always { + echo 'Slack Notifications.' + slackSend ( + channel: '#jenkinscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + ) + + mail ( + to: 'jofranco1203@gmail.com', + subject: "Build ${env.JOB_NAME} - #${env.BUILD_NUMBER} ${currentBuild.currentResult}", + body: "Build details: ${env.BUILD_URL}" + ) + } + } +} \ No newline at end of file From 44756001b40c9be19d34e0b34669aacf3189f7be Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 21:51:46 +0200 Subject: [PATCH 77/78] update prod jenkinsfile --- ProdPipeline/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProdPipeline/Jenkinsfile b/ProdPipeline/Jenkinsfile index cfc2a556b..4fdd6d80a 100644 --- a/ProdPipeline/Jenkinsfile +++ b/ProdPipeline/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { agent any environment { - cluster = "vproprod" + cluster = "bonny-vproprod" service = "vproprodsvc" } From 54d33695638a4ff9965f506e3a26aa385722d23a Mon Sep 17 00:00:00 2001 From: santonix Date: Thu, 12 Sep 2024 22:21:53 +0200 Subject: [PATCH 78/78] modify README file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84ce5d07f..4db4800dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#### +## ### Prerequisites - JDK 1.8 or later - Maven 3 or later