Skip to content

Commit

Permalink
Updated jenkinsfile for better rocketchatt notifications. Also fixed …
Browse files Browse the repository at this point in the history
…some simple sonarqube bugs
  • Loading branch information
SteveMHoward committed Jan 23, 2020
1 parent b11a5b3 commit eb9a8c6
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 44 deletions.
57 changes: 31 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
Expand Down Expand Up @@ -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
)

Expand All @@ -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
)

Expand Down Expand Up @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand All @@ -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
)

Expand All @@ -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"
Expand Down Expand Up @@ -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'
Expand All @@ -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
)

Expand All @@ -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
)

Expand All @@ -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"
Expand All @@ -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
)
}
}
}
}
}
12 changes: 6 additions & 6 deletions Jenkinsfile - deploy to prod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]}`;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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'])),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit eb9a8c6

Please sign in to comment.