Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions pkg/app/piped/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c
shouldTrigger, err := ds.Determiner(c.kind).ShouldTrigger(ctx, app, appCfg)
if err != nil {
msg := fmt.Sprintf("failed while determining whether application %s should be triggered or not: %s", app.Name, err)
t.notifyDeploymentTriggerFailed(app, msg, headCommit)
t.notifyDeploymentTriggerFailed(app, appCfg, msg, headCommit)
t.logger.Error(msg, zap.Error(err))
continue
}
Expand Down Expand Up @@ -274,7 +274,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c
deployment, err := t.triggerDeployment(ctx, app, appCfg, branch, headCommit, commander, strategy, strategySummary)
if err != nil {
msg := fmt.Sprintf("failed to trigger application %s: %v", app.Id, err)
t.notifyDeploymentTriggerFailed(app, msg, headCommit)
t.notifyDeploymentTriggerFailed(app, appCfg, msg, headCommit)
t.logger.Error(msg, zap.Error(err))
continue
}
Expand Down Expand Up @@ -412,14 +412,20 @@ func (t *Trigger) notifyDeploymentTriggered(ctx context.Context, appCfg *config.
}
}

func (t *Trigger) notifyDeploymentTriggerFailed(app *model.Application, reason string, commit git.Commit) {
func (t *Trigger) notifyDeploymentTriggerFailed(app *model.Application, appCfg *config.GenericDeploymentSpec, reason string, commit git.Commit) {
var mentions []string
if n := appCfg.DeploymentNotification; n != nil {
mentions = n.FindSlackAccounts(model.NotificationEventType_EVENT_DEPLOYMENT_TRIGGER_FAILED)
}

t.notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_TRIGGER_FAILED,
Metadata: &model.NotificationEventDeploymentTriggerFailed{
Application: app,
CommitHash: commit.Hash,
CommitMessage: commit.Message,
Reason: reason,
Application: app,
CommitHash: commit.Hash,
MentionedAccounts: mentions,
CommitMessage: commit.Message,
Reason: reason,
},
})
}
Expand Down
1 change: 1 addition & 0 deletions pkg/model/notificationevent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ message NotificationEventDeploymentTriggerFailed {
string commit_hash = 2 [(validate.rules).string.min_len = 1];
string commit_message = 3 [(validate.rules).string.min_len = 1];
string reason = 4 [(validate.rules).string.min_len = 1];
repeated string mentioned_accounts = 5;
}

message NotificationEventApplicationSynced {
Expand Down