Skip to content

Commit

Permalink
CodeBuild Events support - add option to Settings to enable/disable C…
Browse files Browse the repository at this point in the history
…odeBuild support
  • Loading branch information
danilvalov committed Apr 23, 2024
1 parent 62402de commit 20ce9eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"help_text": "Generated token to validate incoming requests from AWS SNS.",
"placeholder": "",
"default": null
},
{
"key": "EnableCodeBuildNotifications",
"display_name": "Enable CodeBuild notifications support:",
"type": "bool",
"help_text": "Enable to add support for handling CodeBuild SNS notifications.",
"placeholder": "",
"default": false
}
]
}
Expand Down
7 changes: 4 additions & 3 deletions server/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
// If you add non-reference types to your configuration struct, be sure to rewrite Clone as a deep
// copy appropriate for your types.
type configuration struct {
TeamChannel string
AllowedUserIds string
Token string
TeamChannel string
AllowedUserIds string
Token string
EnableCodeBuildNotifications bool
}

// Clone shallow copies the configuration. Your implementation may require a deep copy if
Expand Down
6 changes: 5 additions & 1 deletion server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ func (p *Plugin) handleNotification(body io.Reader, channel *TeamChannel) {

if isCodeBuild, messageNotification := p.isCodeBuildEvent(notification.Message); isCodeBuild {
p.API.LogDebug("Processing CodeBuild Event")
p.sendPostNotification(p.createSNSCodeBuildEventNotificationAttachment(notification.Subject, messageNotification), channel)

if p.configuration.EnableCodeBuildNotifications {
p.sendPostNotification(p.createSNSCodeBuildEventNotificationAttachment(notification.Subject, messageNotification), channel)
}

return
}

Expand Down

0 comments on commit 20ce9eb

Please sign in to comment.