Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/slack-markdown.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<% pipelineUrl = String.format("<%spipeline|#%s>", jobUrl, build?.id ?: 'build')%>
<% testsUrl = String.format("<%stests|here>", jobUrl)%>
<% changesMessage = (changes?.msg) ? "${commitUrl} (by `${changes?.author?.id}`)" : "No push event to branch ${build?.pipeline}" %>
<% tookMessage = (duration?.trim()) ? "(Took `${duration}`)" : '' %>
<% stepsMessage = (steps?.size()!= 0) ? "*Steps failures*: `${steps?.size()}` (click ${artifactsUrl} and open `build.md` for further details)" : ""%>
<% if (header?.trim()) {%>${header}<%}%>
*Build*: `${jenkinsText}` ${pipelineUrl} for branch `${build?.pipeline}` got the status `${buildStatus}`
*Build*: `${jenkinsText}` ${pipelineUrl} for branch `${build?.pipeline}` got the status `${buildStatus}`. ${tookMessage}
*Changes*: ${changesMessage}
*Tests*: `${(testsSummary?.failed) ?: 0}` test/s failed out of ${(testsSummary?.total) ?: 0} (click ${testsUrl} for further details)
${stepsMessage}
2 changes: 2 additions & 0 deletions src/co/elastic/NotificationManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def notifySlack(Map args = [:]) {

if (enabled) {
catchError(buildResult: 'SUCCESS', message: 'notifySlack: Error with the slack comment') {
def duration = (build.durationInMillis?.toString()?.trim()) ? hudson.Util.getTimeSpanString(build.durationInMillis) : ''
def statusSuccess = (buildStatus == "SUCCESS")
def boURL = getBlueoceanDisplayURL()
def body = buildTemplate([
Expand All @@ -293,6 +294,7 @@ def notifySlack(Map args = [:]) {
"buildStatus": buildStatus,
"changeSet": changeSet,
"docsUrl": docsUrl,
"duration": duration,
"jenkinsText": env.JOB_NAME,
"jenkinsUrl": env.JENKINS_URL,
"jobUrl": boURL,
Expand Down
1 change: 1 addition & 0 deletions src/test/groovy/NotificationManagerStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ class NotificationManagerStepTests extends ApmBasePipelineTest {
assertTrue(assertMethodCallContainsPattern('slackSend', 'Steps failures'))
assertTrue(assertMethodCallContainsPattern('slackSend', 'https://github.com/org/acme/issues/1234|indicator type url is in upper case (#1234)'))
assertTrue(assertMethodCallContainsPattern('slackSend', 'by `Lola.Flores`'))
assertTrue(assertMethodCallContainsPattern('slackSend', 'Took'))
assertJobStatusSuccess()
}

Expand Down