Skip to content

Commit

Permalink
feat: move slack notifications to discord
Browse files Browse the repository at this point in the history
  • Loading branch information
annybs committed Jan 21, 2022
1 parent a843947 commit d7822e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
31 changes: 3 additions & 28 deletions .jenkins/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by a GNU GPL-style license
// that can be found in the LICENSE.md file. All rights reserved.

def imagesPushed = ''

def buildAndPushImage(registry, tag, isTestnet, blockchainApi, indexApi, explorerUrl, bridgeWalletAddress) {
docker.withRegistry("https://$registry", registry) {
def image = docker.build("$registry/$tag",
Expand All @@ -17,15 +15,6 @@ def buildAndPushImage(registry, tag, isTestnet, blockchainApi, indexApi, explore
pipeline {
agent any
stages {
//
// Notify the team
//
stage('Notify') {
steps {
slackSend color: 'good', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has started."
}
}

//
// Build image
//
Expand All @@ -39,10 +28,6 @@ pipeline {
steps {
script {
def tag = buildAndPushImage(REGISTRY, NAME, IS_TESTNET, BLOCKCHAIN_API_URL, INDEX_API_URL, EXPLORER_URL, BRIDGE_WALLET_ADDRESS)

// Update image list for slack reporting.
if (imagesPushed == '') imagesPushed = "\n$tag"
else imagesPushed = "$imagesPushed\n$tag"
}
}
}
Expand All @@ -52,27 +37,17 @@ pipeline {
post {
success {
script {
if (imagesPushed != '') {
slackSend color: 'good', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has completed successfully, pushing images $imagesPushed"
}
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has completed successfully", result:"SUCCESS", webhookURL: DISCORD_BUILD_WEBHOOK
}
}
failure {
script {
if (imagesPushed != '') {
slackSend color: 'danger', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has failed, but pushed images $imagesPushed\n\nView logs: ${env.BUILD_URL}console"
} else {
slackSend color: 'danger', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has failed.\n\nView logs: ${env.BUILD_URL}console"
}
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has failed", result:"FAILURE", webhookURL: DISCORD_BUILD_WEBHOOK
}
}
aborted {
script {
if (imagesPushed != '') {
slackSend color: 'warning', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) was aborted, but pushed images $imagesPushed\n\nView logs: ${env.BUILD_URL}console"
} else {
slackSend color: 'warning', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) was aborted.\n\nView logs: ${env.BUILD_URL}console"
}
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) was aborted", result:"WARNING", webhookURL: DISCORD_BUILD_WEBHOOK
}
}
}
Expand Down
15 changes: 3 additions & 12 deletions .jenkins/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ def deployScript() {
pipeline {
agent any
stages {
//
// Notify the team
//
stage('Notify') {
steps {
slackSend channel: '#edge-deployments', color: 'good', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has started."
}
}

//
// Deploy
//
Expand Down Expand Up @@ -80,17 +71,17 @@ pipeline {
post {
success {
script {
slackSend channel: '#edge-deployments', color: 'good', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has been deployed to ${DEPLOY_TARGET}"
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) has been deployed", result:"SUCCESS", webhookURL: DISCORD_DEPLOY_WEBHOOK
}
}
failure {
script {
slackSend channel: '#edge-deployments', color: 'danger', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) failed to deploy."
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) failed to deploy", result:"FAILURE", webhookURL: DISCORD_DEPLOY_WEBHOOK
}
}
aborted {
script {
slackSend channel: '#edge-deployments', color: 'warning', message: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) was aborted."
discordSend title: JOB_NAME, description: "${env.JOB_NAME} (#${env.BUILD_NUMBER}) was aborted", result:"WARNING", webhookURL: DISCORD_DEPLOY_WEBHOOK
}
}
}
Expand Down

0 comments on commit d7822e2

Please sign in to comment.