Skip to content

Commit e3fc873

Browse files
Merge pull request #190 from IBM/slacknotify
Add slack notifications for build
2 parents 050a938 + 91a798d commit e3fc873

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Jenkinsfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
*/
1919
def RELEASE_BRANCHES = ["master"]
2020

21+
/**
22+
* Branches to send notifcations for
23+
*/
24+
def NOTIFY_BRANCHES = ["master"]
25+
26+
2127
/**
2228
* The following flags are switches to control which stages of the pipeline to be run. This is helpful when
2329
* testing a specific stage of the pipeline.
@@ -611,8 +617,7 @@ pipeline {
611617
if (BRANCH_NAME == MASTER_BRANCH) {
612618
echo "publishing next to $TEST_NPM_REGISTRY"
613619
sh "npm publish --tag next"
614-
}
615-
else {
620+
} else {
616621
echo "publishing latest to $TEST_NPM_REGISTRY"
617622
sh "npm publish --tag latest"
618623
}
@@ -623,5 +628,22 @@ pipeline {
623628
}
624629
}
625630
}
631+
632+
}
633+
post {
634+
unsuccessful {
635+
script {
636+
if (NOTIFY_BRANCHES.contains(BRANCH_NAME)) {
637+
slackSend (channel: '#cics-node-dev', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} completed - ${currentBuild.result} (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'slack-cics-node-dev')
638+
}
639+
}
640+
}
641+
fixed {
642+
script {
643+
if (NOTIFY_BRANCHES.contains(BRANCH_NAME)) {
644+
slackSend (channel: '#cics-node-dev', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} completed - Back to normal (<${env.BUILD_URL}|Open>)", tokenCredentialId: 'slack-cics-node-dev')
645+
}
646+
}
647+
}
626648
}
627649
}

0 commit comments

Comments
 (0)