Send message to post_ar_build SNS topic after build finished (#4442)
* Send message to post_ar_build SNS topic after build finished Signed-off-by: shiranj <shiranj@amazon.com> * Add build number to SNS message Signed-off-by: shiranj <shiranj@amazon.com>
This commit is contained in:
Vendored
+20
-15
@@ -793,27 +793,32 @@ catch(Exception e) {
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if(env.SNS_TOPIC) {
|
||||
snsPublish(
|
||||
topicArn: env.SNS_TOPIC,
|
||||
subject:'Build Result',
|
||||
message:"${currentBuild.currentResult}:${BUILD_URL}:${env.RECREATE_VOLUME}:${env.CLEAN_OUTPUT_DIRECTORY}:${env.CLEAN_ASSETS}"
|
||||
)
|
||||
}
|
||||
node('controller') {
|
||||
if("${currentBuild.currentResult}" == "SUCCESS") {
|
||||
buildFailure = ""
|
||||
emailBody = "${BUILD_URL}\nSuccess!"
|
||||
} else {
|
||||
buildFailure = tm('${BUILD_FAILURE_ANALYZER}')
|
||||
emailBody = "${BUILD_URL}\n${buildFailure}!"
|
||||
if(env.SNS_TOPIC_BUILD_FAILURE) {
|
||||
message_json = ["build_url":env.BUILD_URL, "repository_name":env.REPOSITORY_NAME, "branch_name":env.BRANCH_NAME, "build_failure":buildFailure]
|
||||
snsPublish(
|
||||
topicArn: env.SNS_TOPIC_BUILD_FAILURE,
|
||||
subject:'Build Failure',
|
||||
message:JsonOutput.toJson(message_json)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
if(env.POST_AR_BUILD_SNS_TOPIC) {
|
||||
message_json = [
|
||||
"build_url": env.BUILD_URL,
|
||||
"build_number": env.BUILD_NUMBER,
|
||||
"repository_name": env.REPOSITORY_NAME,
|
||||
"branch_name": env.BRANCH_NAME,
|
||||
"build_result": "${currentBuild.currentResult}",
|
||||
"build_failure": buildFailure,
|
||||
"recreate_volume": env.RECREATE_VOLUME,
|
||||
"clean_output_directory": env.CLEAN_OUTPUT_DIRECTORY,
|
||||
"clean_assets": env.CLEAN_ASSETS
|
||||
]
|
||||
snsPublish(
|
||||
topicArn: env.POST_AR_BUILD_SNS_TOPIC,
|
||||
subject:'Build Result',
|
||||
message:JsonOutput.toJson(message_json)
|
||||
)
|
||||
}
|
||||
emailext (
|
||||
body: "${emailBody}",
|
||||
|
||||
Reference in New Issue
Block a user