diff --git a/resources/slack-markdown.template b/resources/slack-markdown.template index a01d813df..46abcbf6b 100644 --- a/resources/slack-markdown.template +++ b/resources/slack-markdown.template @@ -1,10 +1,10 @@ <% changes = changeSet?.find { true }%> <% steps = stepsErrors?.findAll{it?.result == "FAILURE" && !it?.displayName?.contains('Notifies GitHub') && !it?.displayName?.contains('Archive JUnit')}%> <% artifactsUrl = String.format("<%sartifacts|here>", jobUrl)%> -<% commitUrl = String.format("<%s|%s>", changes?.url, changes?.msg)%> +<% commitUrl = String.format("<%s|%s>", changes?.issues?.first()?.url, changes?.msg)%> <% pipelineUrl = String.format("<%spipeline|#%s>", jobUrl, build?.id ?: 'build')%> <% testsUrl = String.format("<%stests|here>", jobUrl)%> -<% changesMessage = (changes?.url && changes?.msg) ? "${commitUrl} (by `${changes?.author?.id}`)" : "No push event to branch ${build?.pipeline}" %> +<% changesMessage = (changes?.msg) ? "${commitUrl} (by `${changes?.author?.id}`)" : "No push event to branch ${build?.pipeline}" %> <% 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}` diff --git a/src/test/groovy/NotificationManagerStepTests.groovy b/src/test/groovy/NotificationManagerStepTests.groovy index 47c56de07..6d94892e2 100644 --- a/src/test/groovy/NotificationManagerStepTests.groovy +++ b/src/test/groovy/NotificationManagerStepTests.groovy @@ -468,6 +468,8 @@ class NotificationManagerStepTests extends ApmBasePipelineTest { printCallStack() assertTrue(assertMethodCallContainsPattern('slackSend', 'ABORTED')) 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`')) assertJobStatusSuccess() } diff --git a/src/test/resources/changeSet-info.json b/src/test/resources/changeSet-info.json index 7814406ae..df19fa6bb 100644 --- a/src/test/resources/changeSet-info.json +++ b/src/test/resources/changeSet-info.json @@ -1,76 +1,25 @@ -[{ - "_class": "io.jenkins.blueocean.service.embedded.rest.ChangeSetResource", - "_links": { - "self": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/organizations/jenkins/pipelines/apm-server/pipelines/apm-server-mbp/branches/master/runs/198/changeSet/8a2fd55f40dbcb279911e3f2237312baf1508019/" - } - }, - "affectedPaths": ["changelogs/7.0.asciidoc"], - "author": { - "_class": "io.jenkins.blueocean.service.embedded.rest.UserImpl", - "_links": { - "favorites": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/users/someone/favorites/" - }, - "self": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/users/someone/" - } +[ + { + "affectedPaths": [ + "pipeline.yml" + ], + "author": { + "avatar": null, + "email": null, + "fullName": "Lola Flores", + "id": "Lola.Flores", + "permission": null }, - "avatar": null, - "email": "someone@example.com", - "fullName": "Jhon Doe", - "id": "someone", - "permission": null - }, - "checkoutCount": 0, - "commitId": "8a2fd55f40dbcb279911e3f2237312baf1508019", - "issues": [{ - "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubIssue", - "id": "#2207", - "url": "https://github.com/elastic/apm-server/issues/2207" - }], - "msg": "fix 7.x changelog links (#2207)", - "timestamp": "2019-05-23T16:37:37.000+0000", - "url": "https://github.com/elastic/apm-server/commit/8a2fd55f40dbcb279911e3f2237312baf1508019" -}, -{ - "_class": "io.jenkins.blueocean.service.embedded.rest.ChangeSetResource", - "_links": { - "self": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/organizations/jenkins/pipelines/apm-server/pipelines/apm-server-mbp/branches/master/runs/198/changeSet/8a2fd55f40dbcb279911e3f2237312baf1508019/" - } - }, - "affectedPaths": ["changelogs/7.0.asciidoc"], - "author": { - "_class": "io.jenkins.blueocean.service.embedded.rest.UserImpl", - "_links": { - "favorites": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/users/someone/favorites/" - }, - "self": { - "_class": "io.jenkins.blueocean.rest.hal.Link", - "href": "/blue/rest/users/someone/" + "checkoutCount": 0, + "commitId": "abcdefg", + "issues": [ + { + "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubIssue", + "id": "#1234", + "url": "https://github.com/org/acme/issues/1234" } - }, - "avatar": null, - "email": "someone@example.com", - "fullName": "Jhon Doe", - "id": "someone", - "permission": null - }, - "checkoutCount": 0, - "commitId": "8a2fd55f40dbcb279911e3f2237312baf1508019", - "issues": [{ - "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubIssue", - "id": "#2207", - "url": "https://github.com/elastic/apm-server/issues/2207" - }], - "msg": "fix 7.x changelog links (#2207)", - "timestamp": "2019-05-23T16:37:37.000+0000", - "url": "https://github.com/elastic/apm-server/commit/8a2fd55f40dbcb279911e3f2237312baf1508019" -}] + ], + "msg": "indicator type url is in upper case (#1234)", + "timestamp": "2021-02-22T10:23:51.000+0000" + } +]