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 7e849c20a..383458502 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 @@ -81,20 +81,9 @@ class EmailNotificationAgent extends AbstractEventNotificationAgent { String link = "${spinnakerUrl}/#/applications/${application}/${config.type == 'stage' ? 'executions/details' : config.link }/${event.content?.execution?.id}" - def engine = new groovy.text.SimpleTemplateEngine() - event.content.parameters = event.content?.execution?.trigger?.parameters - - def expandEmail = { address -> - if (address != null && address != "") { - return [ engine.createTemplate(address as String).make(event.content) ] as String[] - } - - return null - } - sendMessage( - expandEmail(preference.address), - expandEmail(preference.cc), + preference.address ? [preference.address] as String[] : null, + preference.cc ? [preference.cc] as String[] : null, event, subject, config.type, 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 f9501a157..bdfaaf133 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 @@ -163,49 +163,4 @@ class EmailNotificationAgentSpec extends Specification { name: "foo-stage", execution: [id: "abc", name: "foo-pipeline"]]) } - - def "expand email address/cc from parameters"() { - given: - def email = new BlockingVariables() - mailService.send(*_) >> { to, cc, subject, text -> - email.to = to - email.cc = cc - email.subject = subject - email.text = text - } - - when: - agent.sendNotifications( - [address: address, cc: cc], - application, - event, - [type: "stage"], - status - ) - - then: - email.to == ["fake@email.com"] - email.cc == ["fakecc@email.com"] - - and: - 0 * _ - - where: - customSubject = "A custom subject" - customBody = "A **custom** body" - application = "whatever" - address = '''${parameters.EmailTo}''' - cc = '''${parameters.EmailCc}''' - status = "complete" - pipelineName = "foo-pipeline" - stageName = "foo-stage" - trigger = [ parameters: [EmailTo: "fake@email.com", - EmailCc: "fakecc@email.com", - ]] - - event = new Event(content: [context: [customSubject: customSubject, - customBody: customBody], - name: "foo-stage", - execution: [id: "abc", name: "foo-pipeline", trigger: trigger]]) - } }