From bfec72b26a736634e01ce964f99c0fc2fbd7a5b9 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:51:27 +0530 Subject: [PATCH 01/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index 630c2e6..96bd073 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -43,10 +43,13 @@ stages { echo 'I am executing code quality using sonarqube' sh 'mvn -f sample-java-app/pom.xml sonar:sonar' } - /* sleep(60) + sleep(60) timeout(time: 1, unit: 'MINUTES') { waitForQualityGate abortPipeline: true - } */ + } + + + } } } @@ -68,7 +71,7 @@ stages { sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' sh 'ls -lrt sample-java-app/target/' - sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' + sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' echo "noooooooooooooooooo" } } @@ -108,8 +111,9 @@ stages { } } } - } - stage('Post Deploy Tests') { + } + + stage('Post Deploy Tests') { parallel { stage('Smoke Test') { steps { From 09eacabfb6136c97b70cf3c806783ece1204212d Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:55:31 +0530 Subject: [PATCH 02/11] Update Jenkinsfile_AIP From 3385f0b9b15ab78bc620af552afaff7c0db55ee6 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:58:24 +0530 Subject: [PATCH 03/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 145 +----------------------------------------------- 1 file changed, 1 insertion(+), 144 deletions(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index 96bd073..a879060 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -1,6 +1,5 @@ pipeline { - - agent { + agent { kubernetes { label 'SpringBootRestApp' defaultContainer 'jnlp' @@ -35,148 +34,6 @@ stages { } } } - stage('Code Quality') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName: 'Sonarqube') { - echo 'I am executing code quality using sonarqube' - sh 'mvn -f sample-java-app/pom.xml sonar:sonar' - } - sleep(60) - timeout(time: 1, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true - } - - - - } - } - } - } - stage("Publish Package") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { - withMaven(maven: 'MAVEN-3.6.3') { - echo 'I am pushing the artifact with unique name showing the branch from which it is generated, to Archiva' - /* echo 'copying the jar and war files from the individual target directorrys and copying it to artifacts directory ' - sh "mkdir -p $WORKSPACE/artifacts" - sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do cp -rp ${i}/dist/libs/* $WORKSPACE/artifacts/ ;done' */ - /* echo 'create a tar file on the Jenkins server' - sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ - sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' - sh 'ls -lrt sample-java-app/target/' - sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' - echo "noooooooooooooooooo" - } - } - } - } - } - } - stage("Deploy") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { - withMaven(maven: 'MAVEN-3.6.3') { - echo 'I am deploying the artifact into the target environment' - echo 'shutting down the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH stop || sleep 20"' - echo 'force stop any remaining mule process' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' */ - echo 'tomcat server stopped' - echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' - /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_DIR && rm -rf $ESB_WAR_FOLDERS && cp -rp $DEPLOYMENT_STAGE_DIR/*.war $DEPLOYMENT_DIR"' */ - echo 'Deployment has been completed' - echo 'starting the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH start"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "sleep 20"' */ - echo 'tomcat server started' - } - } else { - echo "no need" - } - } - } - } - } - stage('Post Deploy Tests') { - parallel { - stage('Smoke Test') { - steps { - echo "I am executing Smoke Test on target dev environment post deployment" - } - /*RESP=`curl -X GET "${bamboo.uri}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` - echo "The response for current execution status is: $RESP" - if [ "$RESP" != "[]" ]; - then - echo "There is a test executing currently in Worksoft. Hence, not proceeding with the execution of Worksoft test cases." - exit 1 - else - echo "There are no tests executing right now. Hence, proceeding with Worksoft test execution" - fi - # To abort the request before attempting to re-run, uncomment and run below line. - # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/Request/${bamboo.RequestID}/abort/) - guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${bamboo.stage_name}}" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/ExecuteRequest/ | tr -d \") - echo "The GUID is: $guid" - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) - echo "The status is: $status" - while [[ $status != *"Completed"* ]] - do - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) - echo "The status is: $status" - sleep 15 - done - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/) - echo "The status is: $status" - execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) - echo "The exec status is: $execstatus" - if [[ $execstatus != *Passed* ]]; - then - echo "Failed" - exit 1 - else - echo "Passed" - exit - fi - exit */ - } - stage('Security Test') { - steps { - echo 'I am running Security Test here' - } - } - } - } - } - post { - failure { - /*mail bcc: '', - body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", - cc: '', - charset: 'UTF-8', - from: '', - mimeType: 'text/html', - replyTo: '', - subject: "ERROR CI: Project name -> ${env.JOB_NAME}", - to: "foo@foomail.com";*/ - echo 'I am sending a notification with failure' - } - success { - echo 'I am sending a notification with success' - } } } From 62a27575e8c1b15f5d1348f20efc551e11f050e1 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Wed, 3 Feb 2021 20:00:12 +0530 Subject: [PATCH 04/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index a879060..6918240 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -1,5 +1,6 @@ pipeline { - agent { + + agent { kubernetes { label 'SpringBootRestApp' defaultContainer 'jnlp' From e2438affb5c11cd8597a115fd3bc13c96d0c42a8 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Wed, 3 Feb 2021 20:06:44 +0530 Subject: [PATCH 05/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index 6918240..96bd073 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -35,6 +35,148 @@ stages { } } } + stage('Code Quality') { + steps { + container('gradle') { + withMaven(maven: 'MAVEN-3.6.3') { + withSonarQubeEnv(installationName: 'Sonarqube') { + echo 'I am executing code quality using sonarqube' + sh 'mvn -f sample-java-app/pom.xml sonar:sonar' + } + sleep(60) + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + + + + } + } + } + } + stage("Publish Package") { + steps { + container('gradle') { + script { + propfile = readProperties(file: './project.properties') + println("deploy:" + propfile['feature_deploy']) + println("reading properties ...") + if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am pushing the artifact with unique name showing the branch from which it is generated, to Archiva' + /* echo 'copying the jar and war files from the individual target directorrys and copying it to artifacts directory ' + sh "mkdir -p $WORKSPACE/artifacts" + sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do cp -rp ${i}/dist/libs/* $WORKSPACE/artifacts/ ;done' */ + /* echo 'create a tar file on the Jenkins server' + sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ + sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' + sh 'ls -lrt sample-java-app/target/' + sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' + echo "noooooooooooooooooo" + } + } + } + } + } + } + stage("Deploy") { + steps { + container('gradle') { + script { + propfile = readProperties(file: './project.properties') + println("deploy:" + propfile['feature_deploy']) + println("reading properties ...") + if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am deploying the artifact into the target environment' + echo 'shutting down the tomcat ESB server' + /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH stop || sleep 20"' + echo 'force stop any remaining mule process' + sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' */ + echo 'tomcat server stopped' + echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' + /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' + sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' + sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' + sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_DIR && rm -rf $ESB_WAR_FOLDERS && cp -rp $DEPLOYMENT_STAGE_DIR/*.war $DEPLOYMENT_DIR"' */ + echo 'Deployment has been completed' + echo 'starting the tomcat ESB server' + /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH start"' + sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "sleep 20"' */ + echo 'tomcat server started' + } + } else { + echo "no need" + } + } + } + } + } + stage('Post Deploy Tests') { + parallel { + stage('Smoke Test') { + steps { + echo "I am executing Smoke Test on target dev environment post deployment" + } + /*RESP=`curl -X GET "${bamboo.uri}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` + echo "The response for current execution status is: $RESP" + if [ "$RESP" != "[]" ]; + then + echo "There is a test executing currently in Worksoft. Hence, not proceeding with the execution of Worksoft test cases." + exit 1 + else + echo "There are no tests executing right now. Hence, proceeding with Worksoft test execution" + fi + # To abort the request before attempting to re-run, uncomment and run below line. + # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/Request/${bamboo.RequestID}/abort/) + guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${bamboo.stage_name}}" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/ExecuteRequest/ | tr -d \") + echo "The GUID is: $guid" + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + echo "The status is: $status" + while [[ $status != *"Completed"* ]] + do + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + echo "The status is: $status" + sleep 15 + done + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/) + echo "The status is: $status" + execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) + echo "The exec status is: $execstatus" + if [[ $execstatus != *Passed* ]]; + then + echo "Failed" + exit 1 + else + echo "Passed" + exit + fi + exit */ + } + stage('Security Test') { + steps { + echo 'I am running Security Test here' + } + } + } + } + } + post { + failure { + /*mail bcc: '', + body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", + cc: '', + charset: 'UTF-8', + from: '', + mimeType: 'text/html', + replyTo: '', + subject: "ERROR CI: Project name -> ${env.JOB_NAME}", + to: "foo@foomail.com";*/ + echo 'I am sending a notification with failure' + } + success { + echo 'I am sending a notification with success' + } } } From efc77181bf1ef733adb90d00067452ea9d42941a Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Thu, 4 Feb 2021 19:11:46 +0530 Subject: [PATCH 06/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index 96bd073..ce68dfe 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -30,6 +30,7 @@ stages { echo 'I am executing unit test' // sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do gradle --no-daemon -p ${i} clean build;done' sh 'mvn -f sample-java-app/pom.xml clean package' + sh 'mvn -X javadoc:javadoc -o' } } } @@ -43,13 +44,10 @@ stages { echo 'I am executing code quality using sonarqube' sh 'mvn -f sample-java-app/pom.xml sonar:sonar' } - sleep(60) + sleep(60) timeout(time: 1, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } - - - } } } @@ -71,7 +69,7 @@ stages { sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' sh 'ls -lrt sample-java-app/target/' - sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' + sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' echo "noooooooooooooooooo" } } @@ -111,7 +109,7 @@ stages { } } } - } +} stage('Post Deploy Tests') { parallel { @@ -178,5 +176,8 @@ stages { success { echo 'I am sending a notification with success' } + /* always { + javadoc: Publish Javadoc + } */ } } From 9e9b4962fe8caaad581cdc1f51850269be32d405 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Thu, 4 Feb 2021 19:15:01 +0530 Subject: [PATCH 07/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index ce68dfe..13d061d 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -30,12 +30,11 @@ stages { echo 'I am executing unit test' // sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do gradle --no-daemon -p ${i} clean build;done' sh 'mvn -f sample-java-app/pom.xml clean package' - sh 'mvn -X javadoc:javadoc -o' } } } } - } + } stage('Code Quality') { steps { container('gradle') { @@ -109,9 +108,8 @@ stages { } } } -} - - stage('Post Deploy Tests') { + } + stage('Post Deploy Tests') { parallel { stage('Smoke Test') { steps { @@ -176,8 +174,5 @@ stages { success { echo 'I am sending a notification with success' } - /* always { - javadoc: Publish Javadoc - } */ } } From 5c3067efa716ccfd39df6295d12c37f79eb4f21c Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Mon, 15 Feb 2021 21:18:17 +0530 Subject: [PATCH 08/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 275 ++++++++++++++++++++++++++++++------------------ 1 file changed, 170 insertions(+), 105 deletions(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index 13d061d..a625e7d 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -1,10 +1,10 @@ +def propfile pipeline { - - agent { - kubernetes { - label 'SpringBootRestApp' - defaultContainer 'jnlp' - yaml """ + agent { + kubernetes { + label 'SpringBootRestApp' + defaultContainer 'jnlp' + yaml """ apiVersion: v1 kind: Pod metadata: @@ -18,104 +18,154 @@ spec: - cat tty: true """ -} - } - -stages { - stage('Build & Unit Test') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName: 'Sonarqube') { - echo 'I am executing unit test' - // sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do gradle --no-daemon -p ${i} clean build;done' - sh 'mvn -f sample-java-app/pom.xml clean package' + } + } + environment { + GRADLE_PATH = '/opt/gradle/gradle-3.5.1/bin' + GRADLE_TASK = 'ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB' + DEPLOYMENT_ARCHIVE_DIR='/home/muleadmin/stage/archive' + DEPLOYMENT_STAGE_DIR='/home/muleadmin/stage' + DEPLOYMENT_DIR='/opt/mule/latest/webapps' + WAR_FILES='AlertESB.war FraudESB.war TaxESB.war PaymentESB.war FulfillmentESB.war ESBAuditLog.war ESBAutomatedQueueRetry.war OrderReconESB.war' + ESB_BIN_PATH='/opt/mule/bin/esb_service' + ESB_WAR_FOLDERS='PaymentESB ESBAuditLog OrderReconESB FraudESB TaxESB FulfillmentESB AlertESB ESBAutomatedQueueRetry' + REQUESTID='779' + STAGE_NAME='dev3' + WORKSOFT_URI='http://pwwsftapp01/executionmanager/api' + USERNAME='devopsengineering@signetjewelers.com' + USERNAME_FEATURE_DEPLOY='muleadmin' + HOSTS_FEATURE_DEPLOY="10.6.74.90" + USERNAME_DEV_DEPLOY='muleadmin' + HOSTS_DEV_DEPLOY="10.6.74.91, 10.6.74.92" + USERNAME_RELEASE='muleadmin' + HOSTS_RELEASE_DEPLOY="10.6.74.93, 10.6.74.94" + } + stages { + stage('Build & Unit Test') { + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am executing build and unit test' + echo "Use the line below when we switch to the actual repo" + // sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do gradle --no-daemon -p ${i} clean build;done' + echo "Remove the line below when we switch to the actual repo" + sh 'mvn -f sample-java-app/pom.xml clean package' + propfile = readProperties(file: './project.properties') + if (propfile['javadoc'] == "true") { + sh 'mvn javadoc:aggregate' + } + if (propfile['jacoco'] == "true") { + jacoco( + execPattern: '**/*.exec', + classPattern: '**/*.class', + sourcePattern: '**/*.java', + exclusionPattern: '**/test*' + ) + } + } } } } } - } - stage('Code Quality') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName: 'Sonarqube') { + /* stage('Code Quality') { + steps { + container('gradle') { + withMaven(maven: 'MAVEN-3.6.3') { + withSonarQubeEnv(installationName: 'Sonarqube') { echo 'I am executing code quality using sonarqube' - sh 'mvn -f sample-java-app/pom.xml sonar:sonar' + echo ' Update the line below when we switch to actual ESB repo' + // sh './gradle Sonarqube' + echo ' Remove the line below after we switch to ESB repo' + sh 'mvn -f sample-java-app/pom.xml -Dsonar.projectName=ESB_${BRANCH_NAME} -Dsonar.projectKey=ESB_sample sonar:sonar' + } + sleep(60) + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } } - sleep(60) - timeout(time: 1, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true - } } } - } - } - stage("Publish Package") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { - withMaven(maven: 'MAVEN-3.6.3') { + } */ + stage("Publish Package") { + when { expression {env.GIT_BRANCH == 'origin/dev' || env.GIT_BRANCH == 'origin/release'|| propfile['feature_deploy'] == "true" }} + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { echo 'I am pushing the artifact with unique name showing the branch from which it is generated, to Archiva' + echo 'Replace the next 4 lines to reflect the ESB artifact and push it to archiva' + echo 'Use the 5 lines below when we switch to the actual ESB repo' /* echo 'copying the jar and war files from the individual target directorrys and copying it to artifacts directory ' sh "mkdir -p $WORKSPACE/artifacts" - sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do cp -rp ${i}/dist/libs/* $WORKSPACE/artifacts/ ;done' */ - /* echo 'create a tar file on the Jenkins server' - sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ + sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do cp -rp ${i}/dist/libs/* $WORKSPACE/artifacts/ ;done' + echo 'create a tar file on the Jenkins server' + sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true + */ + echo 'Remove the below 3 lines after switching to the actual ESB repo' sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' sh 'ls -lrt sample-java-app/target/' - sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' - echo "noooooooooooooooooo" + sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' } } } } } - } - stage("Deploy") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { - withMaven(maven: 'MAVEN-3.6.3') { - echo 'I am deploying the artifact into the target environment' - echo 'shutting down the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH stop || sleep 20"' - echo 'force stop any remaining mule process' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' */ - echo 'tomcat server stopped' - echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' - /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_DIR && rm -rf $ESB_WAR_FOLDERS && cp -rp $DEPLOYMENT_STAGE_DIR/*.war $DEPLOYMENT_DIR"' */ - echo 'Deployment has been completed' - echo 'starting the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH start"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "sleep 20"' */ - echo 'tomcat server started' - } - } else { - echo "no need" + stage("Deploy") { + when { expression {env.GIT_BRANCH == 'origin/dev' || env.GIT_BRANCH == 'origin/release'|| propfile['feature_deploy'] == "true" }} + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + if (propfile['feature_deploy'] == "true" ) { + USERNAME=env.USERNAME_FEATURE_DEPLOY + HOSTS=env.HOSTS_FEATURE_DEPLOY + } + if (env.BRANCH_NAME == 'dev' ) { + USERNAME=env.USERNAME_DEV_DEPLOY + HOSTS=env.HOSTS_DEV_DEPLOY + } + if (env.BRANCH_NAME == 'release') { + USERNAME=env.USERNAME_RELEASE_DEPLOY + HOSTS=env.HOSTS_RELEASE_DEPLOY + } + HOSTS.tokenize(',').each { HOSTNAME -> + echo "I am deploying the artifact into the target environment ${HOSTNAME} as user ${USERNAME}" + echo 'Replace all the lines below for ESB and add the parameters to propfile and make refrences below' + echo 'Accom logic for multiple env and mult servers in each env based on the branch name' + echo 'shutting down the tomcat ESB server' + /* sh 'ssh ${USERNAME}@${HOSTNAME} "$ESB_BIN_PATH stop || sleep 20"' + echo 'force stop any remaining mule process' + sh 'ssh ${USERNAME}@${HOSTNAME} "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' + */ + echo 'tomcat server stopped' + echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' + /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $}DEPLOYMENT_DIR} && rm -rf ${ESB_WAR_FOLDERS} && cp -rp ${DEPLOYMENT_STAGE_DIR}/*.war $DEPLOYMENT_DIR"' + */ + echo 'Deployment has been completed' + echo 'starting the tomcat ESB server' + /* sh 'ssh ${USERNAME}@${HOSTNAME} "${ESB_BIN_PATH start}"' + sh 'ssh ${USERNAME}@${HOSTNAME} "sleep 20"' + */ + echo 'tomcat server started' + } + } } } } } - } - stage('Post Deploy Tests') { + + + stage('Post Deploy Tests') { parallel { stage('Smoke Test') { steps { echo "I am executing Smoke Test on target dev environment post deployment" } - /*RESP=`curl -X GET "${bamboo.uri}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` + /*RESP=`curl -X GET "${WORKSOFT_URI}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` echo "The response for current execution status is: $RESP" if [ "$RESP" != "[]" ]; then @@ -125,20 +175,20 @@ stages { echo "There are no tests executing right now. Hence, proceeding with Worksoft test execution" fi # To abort the request before attempting to re-run, uncomment and run below line. - # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/Request/${bamboo.RequestID}/abort/) - guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${bamboo.stage_name}}" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/ExecuteRequest/ | tr -d \") + # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${REQUESTID}" ${WORKSOFT_URI}/Request/${REQUESTID}/abort/) + guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${STAGE_NAME}}" -H "id: ${REQUESTID}" ${WORKSOFT_URI}/ExecuteRequest/ | tr -d \") echo "The GUID is: $guid" - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${WORKSOFT_URI}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) echo "The status is: $status" while [[ $status != *"Completed"* ]] do - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${WORKSOFT_URI}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) echo "The status is: $status" sleep 15 done - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/) + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${WORKSOFT_URI}/ExecutionStatus/) echo "The status is: $status" - execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) + execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${WORKSOFT_URI}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) echo "The exec status is: $execstatus" if [[ $execstatus != *Passed* ]]; then @@ -152,27 +202,42 @@ stages { } stage('Security Test') { steps { - echo 'I am running Security Test here' - } - } - } - } - } - post { - failure { - /*mail bcc: '', - body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", - cc: '', - charset: 'UTF-8', - from: '', - mimeType: 'text/html', - replyTo: '', - subject: "ERROR CI: Project name -> ${env.JOB_NAME}", - to: "foo@foomail.com";*/ - echo 'I am sending a notification with failure' - } - success { - echo 'I am sending a notification with success' + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am running Security Test here' + } + } + } + } + } + } } - } + + } + + post { + always { + script { + if (propfile['javadoc'] == "true") { + javadoc(javadocDir: "/home/jenkins/agent/workspace/${env.JOB_NAME}/target/site/apidocs", keepAll: true) + } + } + } + failure { + /*mail bcc: '', + body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", + cc: '', + charset: 'UTF-8', + from: '', + mimeType: 'text/html', + replyTo: '', + subject: "ERROR CI: Project name -> ${env.JOB_NAME}", + to: "foo@foomail.com";*/ + echo 'I am sending a notification with failure' + } + success { + echo 'I am sending a notification with success' + } + } } From de8a6e870c29602bc2ba5257a33881f651248d6c Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Mon, 15 Feb 2021 21:18:59 +0530 Subject: [PATCH 09/11] Update pom.xml --- sample-java-app/pom.xml | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sample-java-app/pom.xml b/sample-java-app/pom.xml index 4b589c0..43aaa8d 100644 --- a/sample-java-app/pom.xml +++ b/sample-java-app/pom.xml @@ -68,6 +68,54 @@ 4.5.3 + + + org.jacoco + jacoco-maven-plugin + 0.8.3 + + + jacoco-initialize + + prepare-agent + + + + jacoco-report + test + + report + + + + + coverage-check + + check + + + target/jacoco-report + ${project.build.directory}/coverage-reports/jacoco.exec + + + CLASS + + com.asimio.demo.Application + + + + LINE + COVEREDRATIO + 80% + + + + + + + + + From 5c7b5ed93b9fa4dfd6e36fa675188abe6dd9916e Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Mon, 15 Feb 2021 21:19:46 +0530 Subject: [PATCH 10/11] Update project.properties --- project.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project.properties b/project.properties index 76c7318..1c7df16 100644 --- a/project.properties +++ b/project.properties @@ -1,2 +1,4 @@ feature_deploy=false servers=lxapp.2378 lxapp.656 lxapp.5376 +javadoc=true +jacoco=true From 61e546013e12c543be09050947a1a6778c849932 Mon Sep 17 00:00:00 2001 From: rakshita-singh02 <75852987+rakshita-singh02@users.noreply.github.com> Date: Mon, 15 Feb 2021 22:07:38 +0530 Subject: [PATCH 11/11] Update Jenkinsfile_AIP --- Jenkinsfile_AIP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index a625e7d..773ef44 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -220,7 +220,7 @@ spec: always { script { if (propfile['javadoc'] == "true") { - javadoc(javadocDir: "/home/jenkins/agent/workspace/${env.JOB_NAME}/target/site/apidocs", keepAll: true) + javadoc(javadocDir: "/$WORKSPACE/target/site/apidocs", keepAll: true) } } }