From eb9a8c63643a4016a7161e19b21eb211ba3f61e1 Mon Sep 17 00:00:00 2001 From: SteveMHoward Date: Thu, 23 Jan 2020 12:13:56 -0800 Subject: [PATCH] Updated jenkinsfile for better rocketchatt notifications. Also fixed some simple sonarqube bugs --- Jenkinsfile | 57 ++++++++++--------- Jenkinsfile - deploy to prod | 12 ++-- src/app/models/user.ts | 2 +- .../add-comment/add-comment.component.ts | 6 +- .../review-comment.component.ts | 2 +- .../review-comments-tab.component.ts | 2 +- .../add-edit-comment-period.component.ts | 6 +- .../document-edit/document-edit.component.ts | 6 +- 8 files changed, 49 insertions(+), 44 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ef47d571..30fc3163 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -276,7 +276,7 @@ def nodejsSonarqube () { echo "sonarqube report failed to complete, or timed out" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n sonarqube report failed to complete, or timed out : ${SONARQUBE_URL}", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n sonarqube report failed to complete, or timed out : ${SONARQUBE_URL}", ROCKET_DEPLOY_WEBHOOK ) @@ -297,7 +297,7 @@ def nodejsSonarqube () { echo "Scan Failed" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Sonarqube scan failed: : ${SONARQUBE_URL}", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Sonarqube scan failed: : ${SONARQUBE_URL}", ROCKET_DEPLOY_WEBHOOK ) @@ -310,7 +310,7 @@ def nodejsSonarqube () { } catch (error) { notifyRocketChat( - "@all The latest build of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n ${error.message}", + "@all *[ADMIN][ERROR]* \n The latest build of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n ${error.message}", ROCKET_DEPLOY_WEBHOOK ) throw error @@ -391,7 +391,7 @@ def zapScanner () { echo "Failed to revert dev image after Zap scan failed, please revert the dev image manually from dev-backup" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n Automatic revert of the deployment also failed, please revert the dev image manually from dev-backup", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n Automatic revert of the deployment also failed, please revert the dev image manually from dev-backup", ROCKET_DEPLOY_WEBHOOK ) @@ -400,7 +400,7 @@ def zapScanner () { } notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n dev mage was reverted", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n dev mage was reverted", ROCKET_DEPLOY_WEBHOOK ) @@ -498,7 +498,7 @@ def postZapToSonar () { echo "Zap report failed to complete, or timed out" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n sonarqube report failed to complete, or timed out : ${SONARQUBE_URL}", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n sonarqube report failed to complete, or timed out : ${SONARQUBE_URL}", ROCKET_DEPLOY_WEBHOOK ) @@ -525,7 +525,7 @@ def postZapToSonar () { echo "Failed to revert dev image after Zap scan failed, please revert the dev image manually from dev-backup" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n Automatic revert of the deployment also failed, please revert the dev image manually from dev-backup", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n Automatic revert of the deployment also failed, please revert the dev image manually from dev-backup", ROCKET_DEPLOY_WEBHOOK ) @@ -534,7 +534,7 @@ def postZapToSonar () { } notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n dev image has been reverted", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Zap scan failed: ${SONARQUBE_URL} \n dev image has been reverted", ROCKET_DEPLOY_WEBHOOK ) @@ -593,7 +593,7 @@ pipeline { echo ">> IMAGE_HASH: ${IMAGE_HASH}" } catch (error) { notifyRocketChat( - "@all The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", + "@all *[ADMIN][ERROR]* \n The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", ROCKET_DEPLOY_WEBHOOK ) throw error @@ -644,7 +644,7 @@ pipeline { echo "Dev image backup failed" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Dev image backup failed", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Dev image backup failed", ROCKET_DEPLOY_WEBHOOK ) @@ -661,7 +661,7 @@ pipeline { echo "Dev image deployment failed" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Dev image deployment failed", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Dev image deployment failed", ROCKET_DEPLOY_WEBHOOK ) @@ -676,7 +676,7 @@ pipeline { } catch (error) { notifyRocketChat( - "@all The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", + "@all *[ADMIN][ERROR]* \n The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", ROCKET_DEPLOY_WEBHOOK ) currentBuild.result = "FAILURE" @@ -720,7 +720,18 @@ pipeline { steps { script { try { + notifyRocketChat( + "@all *[ADMIN][DEV][INPUT]* \n A new version of landuseplanning-admin is now in Dev, build: *${env.BUILD_DISPLAY_NAME}* \n Changes: \n ${CHANGELOG} \n\n _*Input is required to move this build to TEST*_\n${env.BUILD_URL}input", + ROCKET_DEPLOY_WEBHOOK + ) input "Deploy to test?" + } catch (error) { + echo "User has chosen to not deploy to test" + echo ">>>> Pipeline Complete" + currentBuild.result = 'SUCCESS' + return + } + try { // backup echo "Backing up test image..." openshiftTag destStream: 'lup-admin-static', verbose: 'false', destTag: 'test-backup', srcStream: 'lup-admin-static', srcTag: 'test' @@ -730,7 +741,7 @@ pipeline { echo "Test image backup failed" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Test image backup failed", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Test image backup failed", ROCKET_DEPLOY_WEBHOOK ) @@ -747,7 +758,7 @@ pipeline { echo "Test image deployment failed" notifyRocketChat( - "@all The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Test image deployment failed", + "@all *[ADMIN][ERROR]* \n The latest build, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Test image deployment failed", ROCKET_DEPLOY_WEBHOOK ) @@ -760,9 +771,14 @@ pipeline { openshiftVerifyDeployment depCfg: 'admin-angular-on-nginx-test', namespace: 'xti26n-test', replicaCount: 1, verbose: 'false', verifyReplicaCount: 'false', waitTime: 600000 echo ">>>> Deployment Complete" + notifyRocketChat( + "*[ADMIN][TEST]* \n A new version of landuseplanning-admin is now in test, build: *${env.BUILD_DISPLAY_NAME}* \n Changes: \n ${CHANGELOG}", + ROCKET_DEPLOY_WEBHOOK + ) + } catch (error) { notifyRocketChat( - "@all The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", + "@all *[ADMIN][ERROR]* \n The build ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", ROCKET_DEPLOY_WEBHOOK ) currentBuild.result = "FAILURE" @@ -771,16 +787,5 @@ pipeline { } } } - - stage('Success Notifications') { - steps { - script { - notifyRocketChat( - "A new version of landuseplanning-admin is now in Dev, build ${env.BUILD_DISPLAY_NAME} \n Changes: \n ${CHANGELOG}", - ROCKET_DEPLOY_WEBHOOK - ) - } - } - } } } \ No newline at end of file diff --git a/Jenkinsfile - deploy to prod b/Jenkinsfile - deploy to prod index 86d7de14..80d7ccfb 100644 --- a/Jenkinsfile - deploy to prod +++ b/Jenkinsfile - deploy to prod @@ -92,7 +92,7 @@ pipeline { ROCKET_DEPLOY_WEBHOOK = sh(returnStdout: true, script: 'cat rocket-deploy-webhook') } catch (error) { notifyRocketChat( - "@all The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", + "@all *[ADMIN][ERROR]* \n The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", ROCKET_DEPLOY_WEBHOOK ) throw error @@ -115,7 +115,7 @@ pipeline { echo "Prod image backup failed" notifyRocketChat( - "@all The latest deployment, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n prod image backup failed", + "@all *[ADMIN][ERROR]* \n The latest deployment, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n prod image backup failed", ROCKET_DEPLOY_WEBHOOK ) @@ -132,7 +132,7 @@ pipeline { echo "Prod image deployment failed" notifyRocketChat( - "@all The latest deployment, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Prod image deployment failed", + "@all *[ADMIN][ERROR]* \n The latest deployment, ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin seems to be broken. \n ${env.BUILD_URL}\n Error: \n Prod image deployment failed", ROCKET_DEPLOY_WEBHOOK ) @@ -143,7 +143,7 @@ pipeline { } } catch (error) { notifyRocketChat( - "@all The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", + "@all *[ADMIN][ERROR]* \n The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: \n ${error.message}", ROCKET_DEPLOY_WEBHOOK ) throw error @@ -162,7 +162,7 @@ pipeline { } catch (error) { notifyRocketChat( - "@all The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", + "@all *[ADMIN][ERROR]* \n The deployment ${env.BUILD_DISPLAY_NAME} of landuseplanning-admin, seems to be broken.\n ${env.BUILD_URL}\n Error: ${error.message}", ROCKET_DEPLOY_WEBHOOK ) currentBuild.result = "FAILURE" @@ -176,7 +176,7 @@ pipeline { steps { script { notifyRocketChat( - "A new version of landuseplanning-admin is now in Production, build ${env.BUILD_DISPLAY_NAME} \n Changes: \n ${CHANGELOG}", + "*[ADMIN][PROD]* \n A new version of landuseplanning-admin is now in Production, build ${env.BUILD_DISPLAY_NAME} \n Changes: \n ${CHANGELOG}", ROCKET_DEPLOY_WEBHOOK ) } diff --git a/src/app/models/user.ts b/src/app/models/user.ts index 15f9b947..2b92fc03 100644 --- a/src/app/models/user.ts +++ b/src/app/models/user.ts @@ -48,7 +48,7 @@ export class User { this.notes = obj && obj.notes || undefined; this.checkbox = obj && obj.checkbox || undefined; - Object.keys(obj).map(e => { + Object.keys(obj).forEach(e => { this[`${e}`] = `${obj[e]}`; }); } diff --git a/src/app/project/comment-period/add-comment/add-comment.component.ts b/src/app/project/comment-period/add-comment/add-comment.component.ts index ea674fd7..f9aefaca 100644 --- a/src/app/project/comment-period/add-comment/add-comment.component.ts +++ b/src/app/project/comment-period/add-comment/add-comment.component.ts @@ -170,7 +170,7 @@ export class AddCommentComponent implements OnInit, OnDestroy { this.addCommentForm.controls.isDeferred.setValue(false); this.addCommentForm.controls.isRejected.setValue(true); - this.documents.map(document => { + this.documents.forEach(document => { document.eaoStatus = 'Rejected'; }); } else { @@ -183,7 +183,7 @@ export class AddCommentComponent implements OnInit, OnDestroy { this.addCommentForm.controls.isPublished.setValue(false); this.addCommentForm.controls.isDeferred.setValue(false); this.addCommentForm.controls.isRejected.setValue(false); - this.documents.map(document => { + this.documents.forEach(document => { document.eaoStatus = 'Pending'; }); break; @@ -207,7 +207,7 @@ export class AddCommentComponent implements OnInit, OnDestroy { private setDocumentForm() { let docForms = []; - this.documents.map(doc => { + this.documents.forEach(doc => { const formData = new FormData(); formData.append('upfile', doc.upfile); formData.append('project', this.currentProject._id); diff --git a/src/app/project/comment-period/review-comment/review-comment.component.ts b/src/app/project/comment-period/review-comment/review-comment.component.ts index 11cb94e6..c7fc5b4f 100644 --- a/src/app/project/comment-period/review-comment/review-comment.component.ts +++ b/src/app/project/comment-period/review-comment/review-comment.component.ts @@ -195,7 +195,7 @@ export class ReviewCommentComponent implements OnInit, OnDestroy { this.commentReviewForm.controls.isDeferred.setValue(false); this.commentReviewForm.controls.isRejected.setValue(true); - this.comment.documentsList.map(document => { + this.comment.documentsList.forEach(document => { document.eaoStatus = 'Rejected'; }); } else { diff --git a/src/app/project/comment-period/review-comments-tab/review-comments-tab.component.ts b/src/app/project/comment-period/review-comments-tab/review-comments-tab.component.ts index 3e0ce7af..aa409a14 100644 --- a/src/app/project/comment-period/review-comments-tab/review-comments-tab.component.ts +++ b/src/app/project/comment-period/review-comments-tab/review-comments-tab.component.ts @@ -157,7 +157,7 @@ export class ReviewCommentsTabComponent implements OnInit, OnDestroy { setCommentRowData() { let commentList = []; - this.comments.map(comment => { + this.comments.forEach(comment => { commentList.push( { _id: comment._id, diff --git a/src/app/project/comment-periods/add-edit-comment-period/add-edit-comment-period.component.ts b/src/app/project/comment-periods/add-edit-comment-period/add-edit-comment-period.component.ts index dd9119cc..af33da25 100644 --- a/src/app/project/comment-periods/add-edit-comment-period/add-edit-comment-period.component.ts +++ b/src/app/project/comment-periods/add-edit-comment-period/add-edit-comment-period.component.ts @@ -58,7 +58,7 @@ export class AddEditCommentPeriodComponent implements OnInit, OnDestroy { // BUG: Go to add docs. refresh. it will redirect and have errors. this.currentProject = this.storageService.state.currentProject.data; - this.config.lists.map(item => { + this.config.lists.forEach(item => { switch (item.type) { case 'doctype': break; @@ -72,7 +72,7 @@ export class AddEditCommentPeriodComponent implements OnInit, OnDestroy { // Get data related to current project this.currentProject = this.storageService.state.currentProject.data; - this.config.lists.map(item => { + this.config.lists.forEach(item => { switch (item.type) { case 'doctype': break; @@ -166,7 +166,7 @@ export class AddEditCommentPeriodComponent implements OnInit, OnDestroy { // Open houses if (this.commentPeriod.openHouses.length > 0) { - this.commentPeriod.openHouses.map(openHouse => { + this.commentPeriod.openHouses.forEach(openHouse => { this.addOpenHouseRowWithFields( this.formBuilder.group({ eventDate: this.utils.convertJSDateToNGBDate(new Date(openHouse['eventDate'])), diff --git a/src/app/project/project-documents/document-edit/document-edit.component.ts b/src/app/project/project-documents/document-edit/document-edit.component.ts index 33434c2a..68af9ce4 100644 --- a/src/app/project/project-documents/document-edit/document-edit.component.ts +++ b/src/app/project/project-documents/document-edit/document-edit.component.ts @@ -52,7 +52,7 @@ export class DocumentEditComponent implements OnInit, OnDestroy { this.documents = this.storageService.state.selectedDocs; this.currentProject = this.storageService.state.currentProject.data; - this.config.lists.map(item => { + this.config.lists.forEach(item => { switch (item.type) { case 'author': this.authors.push(Object.assign({}, item)); @@ -144,7 +144,7 @@ export class DocumentEditComponent implements OnInit, OnDestroy { return label.selected === true; }); - this.documents.map(doc => { + this.documents.forEach(doc => { const formData = new FormData(); formData.append('project', this.currentProject._id); formData.append('documentSource', 'PROJECT'); @@ -213,7 +213,7 @@ export class DocumentEditComponent implements OnInit, OnDestroy { public togglePublish() { this.isPublished = !this.isPublished; let observables = []; - this.documents.map(doc => { + this.documents.forEach(doc => { if (this.isPublished) { observables.push(this.documentService.publish(doc._id)); } else {