diff --git a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgent.groovy b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgent.groovy index f20d00527..747cd10f4 100644 --- a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgent.groovy +++ b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgent.groovy @@ -79,7 +79,7 @@ class EmailNotificationAgent extends AbstractEventNotificationAgent { config.type, status, config.link, - preference.message?."$status"?.text + preference.message?."$config.type.$status"?.text ) } diff --git a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgent.groovy b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgent.groovy index e41437fae..fafcf1e43 100644 --- a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgent.groovy +++ b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgent.groovy @@ -83,8 +83,8 @@ class SlackNotificationAgent extends AbstractEventNotificationAgent { status == 'complete' ? 'completed successfully' : status }""" - if (preference.message?."$status"?.text) { - body += "\n\n" + preference.message[status].text + if (preference.message?."$config.type.$status"?.text) { + body += "\n\n" + preference.message."$config.type.$status".text } String address = preference.address.startsWith('#') ? preference.address : "#${preference.address}" diff --git a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgentSpec.groovy b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgentSpec.groovy index b963be281..ae50ecd6f 100644 --- a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgentSpec.groovy +++ b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/EmailNotificationAgentSpec.groovy @@ -71,7 +71,8 @@ class EmailNotificationAgentSpec extends Specification { event = new Event(content: [context: [stageDetails: [name: "foo-stage"]], execution: [name: "foo-pipeline"]]) } - def "custom text is appended to email body"() { + @Unroll + def "custom text is appended to email body for #status notification"() { given: def email = new BlockingVariables() mailService.send(*_) >> { to, subject, text -> @@ -96,7 +97,7 @@ class EmailNotificationAgentSpec extends Specification { ) then: - context.get().get("message") == message[status].text + context.get().get("message") == message."$type.$status".text where: status | _ @@ -111,7 +112,7 @@ class EmailNotificationAgentSpec extends Specification { stageName = "foo-stage" event = new Event(content: [context: [stageDetails: [name: "foo-stage"]], execution: [name: "foo-pipeline"]]) message = ["complete", "starting", "failed"].collectEntries { - [(it): [text: "custom $it text"]] + [("$type.$it".toString()): [text: "custom $it text"]] } } diff --git a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy index 47fec5c74..978fbfe91 100644 --- a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy +++ b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy @@ -80,7 +80,7 @@ class SlackNotificationAgentSpec extends Specification { event = new Event(content: [execution: [id: "1", name: "foo-pipeline"]]) type = "pipeline" message = ["completed", "starting", "failed"].collectEntries { - [(it): [text: "Custom $it message"]] + [("$type.$it".toString()): [text: "Custom $it message"]] } } }