Skip to content

Commit

Permalink
fix(stage notifications): consuming updated orca payload (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns committed Feb 20, 2018
1 parent 6d3dd4f commit bd3965e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ abstract class AbstractEventNotificationAgent implements EchoEventListener {

// stage level configurations
if (config.type == 'stage') {
if (event.content?.context?.sendNotifications && ( event.content?.context?.stageDetails?.isSynthetic == false ) ) {
boolean isSynthetic = event.content?.isSynthetic?: event.content?.context?.stageDetails?.isSynthetic
if (event.content?.context?.sendNotifications && ( !isSynthetic ) ) {
event.content?.context?.notifications?.each { notification ->
String key = getNotificationType()
if (notification.type == key && notification?.when?.contains("$config.type.$status".toString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class EmailNotificationAgent extends AbstractEventNotificationAgent {
String subject

if (config.type == 'stage') {
subject = """Stage ${context.stageDetails.name} for ${
String stageName = event.content.name ?: context.stageDetails.name
subject = """Stage $stageName for ${
application
}'s ${event.content?.execution?.name} pipeline ${buildInfo}"""
} else if (config.type == 'pipeline') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class HipchatNotificationAgent extends AbstractEventNotificationAgent {
String message = ''

if (config.type == 'stage') {
message = """Stage ${event.content?.context?.stageDetails.name} for """
String stageName = event.content.name ?: event.content?.context?.stageDetails?.name
message = """Stage $stageName for """
}

String link = "${spinnakerUrl}/#/applications/${application}/${config.type == 'stage' ? 'executions/details' : config.link }/${event.content?.execution?.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class SlackNotificationAgent extends AbstractEventNotificationAgent {
String body = ''

if (config.type == 'stage') {
body = """Stage ${event.content?.context?.stageDetails?.name} for """
String stageName = event.content.name ?: event.content?.context?.stageDetails?.name
body = """Stage $stageName for """
}

String link = "${spinnakerUrl}/#/applications/${application}/${config.type == 'stage' ? 'executions/details' : config.link }/${event.content?.execution?.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class TwilioNotificationAgent extends AbstractEventNotificationAgent {
String message = ''

if (config.type == 'stage') {
message = """Stage ${event.content?.context?.stageDetails.name} for """
String stageName = event.content.name ?: event.content?.context?.stageDetails?.name
message = """Stage $stageName for """
}

message +=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class EmailNotificationAgentSpec extends Specification {
status = "complete"
pipelineName = "foo-pipeline"
stageName = "foo-stage"
event = new Event(content: [context: [stageDetails: [name: "foo-stage"]], execution: [name: "foo-pipeline"]])
event = new Event(content: [
execution: [id: "1", name: "foo-pipeline"],
name: "foo-stage"
])
}

@Unroll
Expand Down Expand Up @@ -115,7 +118,7 @@ class EmailNotificationAgentSpec extends Specification {
address = "whoever@netflix.com"
pipelineName = "foo-pipeline"
stageName = "foo-stage"
event = new Event(content: [context: [stageDetails: [name: "foo-stage"]], execution: [name: "foo-pipeline"]])
event = new Event(content: [name: "foo-stage", execution: [name: "foo-pipeline"]])
message = ["complete", "starting", "failed"].collectEntries {
[("$type.$it".toString()): [text: "custom $it text"]]
}
Expand Down Expand Up @@ -156,8 +159,8 @@ class EmailNotificationAgentSpec extends Specification {
pipelineName = "foo-pipeline"
stageName = "foo-stage"
event = new Event(content: [context: [customSubject: customSubject,
customBody: customBody,
stageDetails: [name: "foo-stage"]],
customBody: customBody],
name: "foo-stage",
execution: [id: "abc", name: "foo-pipeline"]])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ class SlackNotificationAgentSpec extends Specification {

channel = "bluespar"
application = "whatever"
event = new Event(content: [execution: [id: "1", name: "foo-pipeline"],
context: [ customMessage: customMessage, stageDetails: [ name: 'a stage' ]]])
event = new Event(content: [
execution: [id: "1", name: "foo-pipeline"],
context: [ customMessage: customMessage ],
name: 'a stage'
])
type = "stage"
}
}

0 comments on commit bd3965e

Please sign in to comment.