Skip to content

Commit

Permalink
Merge pull request #103 from robfletcher/master
Browse files Browse the repository at this point in the history
messages are e.g. 'pipeline.complete' rather than 'complete'
  • Loading branch information
robfletcher authored Oct 11, 2016
2 parents 1703520 + 4cd83d1 commit d618d84
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EmailNotificationAgent extends AbstractEventNotificationAgent {
config.type,
status,
config.link,
preference.message?."$status"?.text
preference.message?."$config.type.$status"?.text
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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 | _
Expand All @@ -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"]]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
}
}
}

0 comments on commit d618d84

Please sign in to comment.