Skip to content

Commit

Permalink
Merge pull request #5 from sakajunquality/feature/fix-notification
Browse files Browse the repository at this point in the history
fix notification
  • Loading branch information
sakajunquality authored Jan 17, 2019
2 parents 8d4a9ab + 5c0c052 commit 3778540
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flow/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ type EventSource struct {
}

type EventRepo struct {
RepoName string `json:"repoName"`
TagName string `json:"tagName"`
RepoName string `json:"repoName"`
TagName *string `json:"tagName"`
BranchName *string `json:"branchName"`
}

type Artifacts struct {
Expand Down
6 changes: 6 additions & 0 deletions flow/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func (f *Flow) notifyRelasePR(e Event, prs PullRequests, app *Application) error
LogURL: e.LogURL,
AppName: app.Name,
Images: e.Images,
TagName: e.TagName,
BranchName: e.BranchName,
PrURL: prURL,
}

Expand All @@ -142,6 +144,8 @@ func (f *Flow) notifyDeploy(e Event) error {
IsPrNotify: false,
LogURL: e.LogURL,
AppName: e.RepoName,
TagName: e.TagName,
BranchName: e.BranchName,
}

return slackbot.NewSlackMessage(f.slackBotToken, cfg.SlackNotifiyChannel, d).Post()
Expand All @@ -153,6 +157,8 @@ func (f *Flow) notifyFalure(e Event, errorMessage string, app *Application) erro
LogURL: e.LogURL,
Images: e.Images,
ErrorMessage: errorMessage,
TagName: e.TagName,
BranchName: e.BranchName,
}

if app != nil {
Expand Down
20 changes: 19 additions & 1 deletion slackbot/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type MessageDetail struct {
Images []string
LogURL string
PrURL string
BranchName *string
TagName *string
Time time.Duration
ErrorMessage string
}
Expand Down Expand Up @@ -53,9 +55,25 @@ func (s *slackMessage) Post() error {
fields = append(fields, slack.AttachmentField{
Title: "App",
Value: s.AppName,
Short: false,
Short: true,
})

if s.BranchName != nil {
fields = append(fields, slack.AttachmentField{
Title: "Branch",
Value: *s.BranchName,
Short: true,
})
}

if s.TagName != nil {
fields = append(fields, slack.AttachmentField{
Title: "Tag",
Value: *s.TagName,
Short: true,
})
}

if len(s.Images) > 0 {
fields = append(fields, slack.AttachmentField{
Title: "Images",
Expand Down

0 comments on commit 3778540

Please sign in to comment.