Skip to content

Commit

Permalink
Revert "fix: use a pipeline parameter in the email address field (#56…
Browse files Browse the repository at this point in the history
…97) (#869)" (#922)

This reverts commit 673e997.
  • Loading branch information
marchello2000 committed Jun 2, 2020
1 parent 0d74983 commit ad45925
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ["[email protected]"]
email.cc == ["[email protected]"]

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: "[email protected]",
EmailCc: "[email protected]",
]]

event = new Event(content: [context: [customSubject: customSubject,
customBody: customBody],
name: "foo-stage",
execution: [id: "abc", name: "foo-pipeline", trigger: trigger]])
}
}

0 comments on commit ad45925

Please sign in to comment.