Skip to content

Commit

Permalink
Add notification during bundle builds (#466)
Browse files Browse the repository at this point in the history
Wiring up a simple notification via Slack integration webhook to keep the team abreast of the builds.

Signed-off-by: Peter Nied <petern@amazon.com>
  • Loading branch information
peternied committed Sep 14, 2021
1 parent 81c0b91 commit 378f171
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bundle-workflow/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ pipeline {
}
}
stage('build') {
agent {
node {
label 'Jenkins-Agent-al2-x64-m5xlarge'
}
}
stages {
stage('build-snapshots') {
environment {
Expand Down Expand Up @@ -87,6 +92,14 @@ pipeline {
}
}
}
post() {
success {
publishNotification(":white_check-mark:", "Successful Build")
}
failure {
publishNotification(":warning:", "Failed Build")
}
}
}
}
}
Expand All @@ -102,4 +115,10 @@ void build() {
s3Upload(file: 'artifacts', bucket: "${ARTIFACT_BUCKET_NAME}", path: "builds/${manifest.build.version}/${OPENSEARCH_BUILD_ID}/${manifest.build.architecture}")
s3Upload(file: "bundle", bucket: "${ARTIFACT_BUCKET_NAME}", path: "bundles/${manifest.build.version}/${OPENSEARCH_BUILD_ID}/${manifest.build.architecture}")
}
}
}

void publishNotification(icon, msg) {
withCredentials([string(credentialsId: 'BUILD_NOTICE_WEBHOOK', variable: 'TOKEN')]) {
sh """curl -XPOST --header "Content-Type: application/json" --data '{"result_text": "$icon ${env.JOB_NAME} [${env.BUILD_NUMBER}] $msg ${env.BUILD_URL}\nManifest: ${BUILD_MANIFEST}"}' $TOKEN"""
}
}

0 comments on commit 378f171

Please sign in to comment.