Skip to content

Commit f164bda

Browse files
committed
Attempt to send failure notifications to integration channel
1 parent 4f618dd commit f164bda

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

Jenkinsfile-SmokeTest

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ def runSmokeTests(Map args = new LinkedHashMap()) {
114114
parallel processes
115115
}
116116

117+
def getMessage(boolean success, String name, String branch, String status, String url) {
118+
return success ? "${name} [`${branch}`] is back in the <${url}|green>! :greendot:" :
119+
":warning: ${name} [`${branch}`] build regression to [${status}]: ${url}"
120+
}
121+
122+
def notify(Map slackArgs) {
123+
// In shared libraries, the `call` method is not in the pipeline CPS context. We need to call the `steps` object to safely call jenkins steps
124+
steps.retry(3) {
125+
return steps.slackSend([ username: 'TinyMCE Angular Smoke Test', failOnError: true ] + slackArgs)
126+
}
127+
}
128+
129+
def notifyOnFailure(String message) {
130+
notify(
131+
channel: '#tinymce-integration-dev',
132+
color: 'danger',
133+
message: "Build ${env.JOB_NAME} #${env.BUILD_NUMBER} failed: ${message} (<${env.BUILD_URL}|Open>)"
134+
)
135+
}
136+
117137
timestamps {
118138
tinyPods.node() {
119139
stage('deps') {
@@ -125,7 +145,13 @@ timestamps {
125145
}
126146

127147
stage('tests') {
128-
runSmokeTests(npm_tag: params.NPM_TAG ?: 'latest')
148+
try {
149+
error("Please ensure that the NPM_TAG parameter is set to a valid npm tag (e.g. 'latest' or 'next') before running the pipeline.")
150+
runSmokeTests(npm_tag: params.NPM_TAG ?: 'latest')
151+
} catch (Exception e) {
152+
echo "Error running smoke tests: ${e}"
153+
notifyOnFailure("TinyMCE Angular - Smoke Tests failed with error: ${e}")
154+
}
129155
}
130156
}
131157
}

0 commit comments

Comments
 (0)