manager: send webhook after build finishes

add an additional and final webhook that notifies of the build status
after completion (success/failure)
This commit is contained in:
Joe Groocock 2020-01-07 13:59:15 +00:00
parent f1dd01e50c
commit 6a59ea777f
No known key found for this signature in database
GPG key ID: E0B16BEACFBB6A86
2 changed files with 13 additions and 0 deletions

View file

@ -437,6 +437,7 @@ func (m *Manager) AfterAll(ctx context.Context, stage *core.Stage) error {
Stages: m.Stages,
Status: m.Status,
Users: m.Users,
Webhook: m.Webhook,
}
return t.do(ctx, stage)
}

View file

@ -37,6 +37,7 @@ type teardown struct {
Status core.StatusService
Stages core.StageStore
Users core.UserStore
Webhook core.WebhookSender
}
func (t *teardown) do(ctx context.Context, stage *core.Stage) error {
@ -167,6 +168,17 @@ func (t *teardown) do(ctx context.Context, stage *core.Stage) error {
Warnln("manager: cannot publish build event")
}
payload := &core.WebhookData{
Event: core.WebhookEventBuild,
Action: core.WebhookActionUpdated,
Repo: repo,
Build: build,
}
err = t.Webhook.Send(noContext, payload)
if err != nil {
logger.WithError(err).Warnln("manager: cannot send global webhook")
}
user, err := t.Users.Find(noContext, repo.UserID)
if err != nil {
logger.WithError(err).