Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor!: redesign webhook events system (#18698)

Danny Xua5de11313b2b
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 93063a9e4c..d60efcf557 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -6329,15 +6329,11 @@ components:
title: Type
enum:
- TYPE_UNSPECIFIED
- - ISSUE_CREATE
- - ISSUE_COMMENT_CREATE
- - ISSUE_FIELD_UPDATE
- - ISSUE_STATUS_UPDATE
- - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- - ISSUE_APPROVAL_NOTIFY
- - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- - NOTIFY_ISSUE_APPROVED
- - NOTIFY_PIPELINE_ROLLOUT
+ - ISSUE_CREATED
+ - ISSUE_APPROVAL_REQUESTED
+ - ISSUE_SENT_BACK
+ - PIPELINE_FAILED
+ - PIPELINE_COMPLETED
description: Activity type enumeration.
bytebase.v1.ActuatorInfo:
type: object
@@ -17496,15 +17492,11 @@ components:
notification_types is the list of activities types that the webhook is interested in.
Bytebase will only send notifications to the webhook if the activity type is in the list.
It should not be empty, and should be a subset of the following:
- - ISSUE_CREATE
- - ISSUE_COMMENT_CREATE
- - ISSUE_FIELD_UPDATE
- - ISSUE_STATUS_UPDATE
- - ISSUE_APPROVAL_NOTIFY
- - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- - NOTIFY_ISSUE_APPROVED
- - NOTIFY_PIPELINE_ROLLOUT
+ - ISSUE_CREATED
+ - ISSUE_APPROVAL_REQUESTED
+ - ISSUE_SENT_BACK
+ - PIPELINE_FAILED
+ - PIPELINE_COMPLETED
title: Webhook
additionalProperties: false
bytebase.v1.WebhookType:
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 8c73687612..e80250914a 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -428,12 +428,16 @@ func (s *IssueService) createIssueDatabaseChange(ctx context.Context, project *s
}
s.stateCfg.ApprovalFinding.Store(issue.UID, issue)
+ // Trigger ISSUE_CREATED webhook
s.webhookManager.CreateEvent(ctx, &webhook.Event{
Actor: user,
- Type: storepb.Activity_ISSUE_CREATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
+ Type: storepb.Activity_ISSUE_CREATED,
Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ IssueCreated: &webhook.EventIssueCreated{
+ CreatorName: user.Name,
+ CreatorEmail: user.Email,
+ },
})
converted, err := s.convertToIssue(issue)
@@ -503,12 +507,16 @@ func (s *IssueService) createIssueGrantRequest(ctx context.Context, project *sto
}
s.stateCfg.ApprovalFinding.Store(issue.UID, issue)
+ // Trigger ISSUE_CREATED webhook
s.webhookManager.CreateEvent(ctx, &webhook.Event{
Actor: user,
- Type: storepb.Activity_ISSUE_CREATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
+ Type: storepb.Activity_ISSUE_CREATED,
Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ IssueCreated: &webhook.EventIssueCreated{
+ CreatorName: user.Name,
+ CreatorEmail: user.Email,
+ },
})
converted, err := s.convertToIssue(issue)
@@ -567,12 +575,16 @@ func (s *IssueService) createIssueDatabaseDataExport(ctx context.Context, projec
}
s.stateCfg.ApprovalFinding.Store(issue.UID, issue)
+ // Trigger ISSUE_CREATED webhook
s.webhookManager.CreateEvent(ctx, &webhook.Event{
Actor: user,
- Type: storepb.Activity_ISSUE_CREATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
+ Type: storepb.Activity_ISSUE_CREATED,
Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ IssueCreated: &webhook.EventIssueCreated{
+ CreatorName: user.Name,
+ CreatorEmail: user.Email,
+ },
})
converted, err := s.convertToIssue(issue)
@@ -675,71 +687,30 @@ func (s *IssueService) ApproveIssue(ctx context.Context, req *connect.Request[v1
if payload.Approval.ApprovalTemplate == nil {
return
}
+ // Notify next approvers if approval is not complete
role := utils.FindNextPendingRole(payload.Approval.ApprovalTemplate, payload.Approval.Approvers)
if role == "" {
return
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_APPROVAL_NOTIFY,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- IssueApprovalCreate: &webhook.EventIssueApprovalCreate{
- Role: role,
- },
- })
- }()
-
- func() {
- if !approved {
+ approvers, err := s.getApproversForRole(ctx, issue.ProjectID, role)
+ if err != nil {
+ slog.Error("failed to get approvers for next role", slog.String("role", role), log.BBError(err))
return
}
- // notify issue approved
+ // Send ISSUE_APPROVAL_REQUESTED webhook
s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_NOTIFY_ISSUE_APPROVED,
+ Actor: user,
+ Type: storepb.Activity_ISSUE_APPROVAL_REQUESTED,
Comment: "",
Issue: webhook.NewIssue(issue),
Project: webhook.NewProject(project),
+ ApprovalRequested: &webhook.EventIssueApprovalRequested{
+ ApprovalRole: role,
+ Approvers: approvers,
+ },
})
-
- // notify pipeline rollout
- if err := func() error {
- if issue.PlanUID == nil {
- return nil
- }
- tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: issue.PlanUID})
- if err != nil {
- return errors.Wrapf(err, "failed to list tasks")
- }
- if len(tasks) == 0 {
- return nil
- }
-
- // Get the first environment from tasks
- firstEnvironment := tasks[0].Environment
- policy, err := GetValidRolloutPolicyForEnvironment(ctx, s.store, firstEnvironment)
- if err != nil {
- return err
- }
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_NOTIFY_PIPELINE_ROLLOUT,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- IssueRolloutReady: &webhook.EventIssueRolloutReady{
- RolloutPolicy: policy,
- StageName: firstEnvironment,
- },
- })
- return nil
- }(); err != nil {
- slog.Error("failed to create rollout release notification activity", log.BBError(err))
- }
}()
// If the issue is a grant request and approved, we will always auto close it.
@@ -770,14 +741,6 @@ func (s *IssueService) ApproveIssue(ctx context.Context, req *connect.Request[v1
}); err != nil {
return errors.Wrapf(err, "failed to create issue comment after changing the issue status")
}
-
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(updatedIssue),
- Project: webhook.NewProject(project),
- })
}
return nil
}(); err != nil {
@@ -806,6 +769,13 @@ func (s *IssueService) RejectIssue(ctx context.Context, req *connect.Request[v1p
if err != nil {
return nil, err
}
+ project, err := s.store.GetProject(ctx, &store.FindProjectMessage{ResourceID: &issue.ProjectID})
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get project"))
+ }
+ if project == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %s not found", issue.ProjectID))
+ }
payload := issue.Payload
if payload.Approval == nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("issue payload approval is nil"))
@@ -867,6 +837,29 @@ func (s *IssueService) RejectIssue(ctx context.Context, req *connect.Request[v1p
slog.Warn("failed to create issue comment", log.BBError(err))
}
+ // Get issue creator for webhook event
+ creator, err := s.store.GetUserByEmail(ctx, issue.CreatorEmail)
+ if err != nil {
+ slog.Warn("failed to get issue creator, using system bot", log.BBError(err))
+ creator = store.SystemBotUser
+ }
+
+ // Trigger ISSUE_SENT_BACK webhook
+ s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: user,
+ Type: storepb.Activity_ISSUE_SENT_BACK,
+ Comment: req.Msg.Comment,
+ Issue: webhook.NewIssue(issue),
+ Project: webhook.NewProject(project),
+ SentBack: &webhook.EventIssueSentBack{
+ ApproverName: user.Name,
+ ApproverEmail: user.Email,
+ CreatorName: creator.Name,
+ CreatorEmail: creator.Email,
+ Reason: req.Msg.Comment,
+ },
+ })
+
issueV1, err := s.convertToIssue(issue)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to convert to issue"))
@@ -943,14 +936,22 @@ func (s *IssueService) RequestIssue(ctx context.Context, req *connect.Request[v1
return
}
+ approvers, err := s.getApproversForRole(ctx, issue.ProjectID, role)
+ if err != nil {
+ slog.Error("failed to get approvers for next role", slog.String("role", role), log.BBError(err))
+ return
+ }
+
+ // Send ISSUE_APPROVAL_REQUESTED webhook
s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_APPROVAL_NOTIFY,
+ Actor: user,
+ Type: storepb.Activity_ISSUE_APPROVAL_REQUESTED,
Comment: "",
Issue: webhook.NewIssue(issue),
Project: webhook.NewProject(project),
- IssueApprovalCreate: &webhook.EventIssueApprovalCreate{
- Role: role,
+ ApprovalRequested: &webhook.EventIssueApprovalRequested{
+ ApprovalRole: role,
+ Approvers: approvers,
},
})
}()
@@ -1023,7 +1024,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
updateMasks := map[string]bool{}
patch := &store.UpdateIssueMessage{}
- var webhookEvents []*webhook.Event
var issueCommentCreates []*store.IssueCommentMessage
for _, path := range req.Msg.UpdateMask.Paths {
updateMasks[path] = true
@@ -1069,17 +1069,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
},
})
- webhookEvents = append(webhookEvents, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_FIELD_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- IssueUpdate: &webhook.EventIssueUpdate{
- Path: path,
- },
- })
-
case "description":
// Prevent updating description if plan exists
if issue.PlanUID != nil {
@@ -1100,17 +1089,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
},
})
- webhookEvents = append(webhookEvents, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_FIELD_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- IssueUpdate: &webhook.EventIssueUpdate{
- Path: path,
- },
- })
-
case "labels":
if len(req.Msg.Issue.Labels) == 0 {
patch.RemoveLabels = true
@@ -1145,9 +1123,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
s.stateCfg.ApprovalFinding.Store(issue.UID, issue)
}
- for _, e := range webhookEvents {
- s.webhookManager.CreateEvent(ctx, e)
- }
if _, err := s.store.CreateIssueComments(ctx, user.Email, issueCommentCreates...); err != nil {
slog.Warn("failed to create issue comments", "issue id", issue.UID, log.BBError(err))
}
@@ -1244,14 +1219,6 @@ func (s *IssueService) BatchUpdateIssuesStatus(ctx context.Context, req *connect
slog.Error("updated issue not found", "issueUID", issueUID)
continue
}
-
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_STATUS_UPDATE,
- Comment: req.Msg.Reason,
- Issue: webhook.NewIssue(updatedIssue),
- Project: webhook.NewProject(project),
- })
}
return connect.NewResponse(&v1pb.BatchUpdateIssuesStatusResponse{}), nil
@@ -1330,14 +1297,6 @@ func (s *IssueService) CreateIssueComment(ctx context.Context, req *connect.Requ
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %s not found", issue.ProjectID))
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_COMMENT_CREATE,
- Comment: req.Msg.IssueComment.Comment,
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- })
-
ic, err := s.store.CreateIssueComments(ctx, user.Email, &store.IssueCommentMessage{
IssueUID: issue.UID,
Payload: &storepb.IssueCommentPayload{
@@ -1439,3 +1398,35 @@ func (s *IssueService) isUserReviewer(ctx context.Context, issue *store.IssueMes
func canRequestIssue(issueCreatorEmail string, user *store.UserMessage) bool {
return issueCreatorEmail == user.Email
}
+
+func (s *IssueService) getApproversForRole(ctx context.Context, projectID string, role string) ([]webhook.User, error) {
+ // Get project IAM policy
+ projectIAM, err := s.store.GetProjectIamPolicy(ctx, projectID)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to get project IAM policy")
+ }
+
+ // Get workspace IAM policy
+ workspaceIAM, err := s.store.GetWorkspaceIamPolicy(ctx)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to get workspace IAM policy")
+ }
+
+ // Get all users with the specified role
+ users := utils.GetUsersByRoleInIAMPolicy(ctx, s.store, role, projectIAM.Policy, workspaceIAM.Policy)
+
+ // Convert to webhook.User format, filtering by END_USER principal type
+ approvers := make([]webhook.User, 0, len(users))
+ for _, user := range users {
+ // Only include END_USER principals as approvers
+ if user.Type != storepb.PrincipalType_END_USER {
+ continue
+ }
+ approvers = append(approvers, webhook.User{
+ Name: user.Name,
+ Email: user.Email,
+ })
+ }
+
+ return approvers, nil
+}
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 04773a29c0..c5be46ae86 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -995,7 +995,7 @@ func (s *ProjectService) TestWebhook(ctx context.Context, req *connect.Request[v
webhookplugin.Context{
URL: webhook.Payload.GetUrl(),
Level: webhookplugin.WebhookInfo,
- EventType: storepb.Activity_ISSUE_CREATE.String(),
+ EventType: storepb.Activity_ISSUE_CREATED.String(),
Title: fmt.Sprintf("Test webhook %q", webhook.Payload.GetTitle()),
TitleZh: fmt.Sprintf("测试 webhook %q", webhook.Payload.GetTitle()),
Description: "This is a test",
diff --git a/backend/api/v1/project_service_converter.go b/backend/api/v1/project_service_converter.go
index 70a5da6399..789ef9fa45 100644
--- a/backend/api/v1/project_service_converter.go
+++ b/backend/api/v1/project_service_converter.go
@@ -58,24 +58,16 @@ func convertToStoreActivityTypes(types []v1pb.Activity_Type) ([]storepb.Activity
switch tp {
case v1pb.Activity_TYPE_UNSPECIFIED:
return nil, common.Errorf(common.Invalid, "activity type must not be unspecified")
- case v1pb.Activity_ISSUE_CREATE:
- result = append(result, storepb.Activity_ISSUE_CREATE)
- case v1pb.Activity_ISSUE_COMMENT_CREATE:
- result = append(result, storepb.Activity_ISSUE_COMMENT_CREATE)
- case v1pb.Activity_ISSUE_FIELD_UPDATE:
- result = append(result, storepb.Activity_ISSUE_FIELD_UPDATE)
- case v1pb.Activity_ISSUE_STATUS_UPDATE:
- result = append(result, storepb.Activity_ISSUE_STATUS_UPDATE)
- case v1pb.Activity_ISSUE_APPROVAL_NOTIFY:
- result = append(result, storepb.Activity_ISSUE_APPROVAL_NOTIFY)
- case v1pb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE:
- result = append(result, storepb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE)
- case v1pb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE:
- result = append(result, storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE)
- case v1pb.Activity_NOTIFY_ISSUE_APPROVED:
- result = append(result, storepb.Activity_NOTIFY_ISSUE_APPROVED)
- case v1pb.Activity_NOTIFY_PIPELINE_ROLLOUT:
- result = append(result, storepb.Activity_NOTIFY_PIPELINE_ROLLOUT)
+ case v1pb.Activity_ISSUE_CREATED:
+ result = append(result, storepb.Activity_ISSUE_CREATED)
+ case v1pb.Activity_ISSUE_APPROVAL_REQUESTED:
+ result = append(result, storepb.Activity_ISSUE_APPROVAL_REQUESTED)
+ case v1pb.Activity_ISSUE_SENT_BACK:
+ result = append(result, storepb.Activity_ISSUE_SENT_BACK)
+ case v1pb.Activity_PIPELINE_FAILED:
+ result = append(result, storepb.Activity_PIPELINE_FAILED)
+ case v1pb.Activity_PIPELINE_COMPLETED:
+ result = append(result, storepb.Activity_PIPELINE_COMPLETED)
default:
return nil, common.Errorf(common.Invalid, "unsupported activity type: %v", tp)
}
@@ -87,24 +79,16 @@ func convertToV1ActivityTypes(types []storepb.Activity_Type) []v1pb.Activity_Typ
var result []v1pb.Activity_Type
for _, tp := range types {
switch tp {
- case storepb.Activity_ISSUE_CREATE:
- result = append(result, v1pb.Activity_ISSUE_CREATE)
- case storepb.Activity_ISSUE_COMMENT_CREATE:
- result = append(result, v1pb.Activity_ISSUE_COMMENT_CREATE)
- case storepb.Activity_ISSUE_FIELD_UPDATE:
- result = append(result, v1pb.Activity_ISSUE_FIELD_UPDATE)
- case storepb.Activity_ISSUE_STATUS_UPDATE:
- result = append(result, v1pb.Activity_ISSUE_STATUS_UPDATE)
- case storepb.Activity_ISSUE_APPROVAL_NOTIFY:
- result = append(result, v1pb.Activity_ISSUE_APPROVAL_NOTIFY)
- case storepb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE:
- result = append(result, v1pb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE)
- case storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE:
- result = append(result, v1pb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE)
- case storepb.Activity_NOTIFY_ISSUE_APPROVED:
- result = append(result, v1pb.Activity_NOTIFY_ISSUE_APPROVED)
- case storepb.Activity_NOTIFY_PIPELINE_ROLLOUT:
- result = append(result, v1pb.Activity_NOTIFY_PIPELINE_ROLLOUT)
+ case storepb.Activity_ISSUE_CREATED:
+ result = append(result, v1pb.Activity_ISSUE_CREATED)
+ case storepb.Activity_ISSUE_APPROVAL_REQUESTED:
+ result = append(result, v1pb.Activity_ISSUE_APPROVAL_REQUESTED)
+ case storepb.Activity_ISSUE_SENT_BACK:
+ result = append(result, v1pb.Activity_ISSUE_SENT_BACK)
+ case storepb.Activity_PIPELINE_FAILED:
+ result = append(result, v1pb.Activity_PIPELINE_FAILED)
+ case storepb.Activity_PIPELINE_COMPLETED:
+ result = append(result, v1pb.Activity_PIPELINE_COMPLETED)
default:
result = append(result, v1pb.Activity_TYPE_UNSPECIFIED)
}
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 3a334e3048..038d81e73e 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -252,7 +252,7 @@ func (s *RolloutService) CreateRollout(ctx context.Context, req *connect.Request
}
}
- if err := CreateRolloutAndPendingTasks(ctx, s.store, s.webhookManager, plan, nil, project, tasks); err != nil {
+ if err := CreateRolloutAndPendingTasks(ctx, s.store, plan, nil, project, tasks); err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
@@ -332,7 +332,6 @@ func (s *RolloutService) ListTaskRuns(ctx context.Context, req *connect.Request[
func CreateRolloutAndPendingTasks(
ctx context.Context,
s *store.Store,
- webhookManager *webhook.Manager,
plan *store.PlanMessage,
issue *store.IssueMessage,
project *store.ProjectMessage,
@@ -384,14 +383,6 @@ func CreateRolloutAndPendingTasks(
}); err != nil {
return errors.Wrapf(err, "failed to create issue comment after changing the issue status")
}
-
- webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(updatedIssue),
- Project: webhook.NewProject(project),
- })
}
// Check if we should auto-rollout
@@ -441,19 +432,6 @@ func CreateRolloutAndPendingTasks(
if err := s.CreatePendingTaskRuns(ctx, common.SystemBotEmail, create); err != nil {
return errors.Wrapf(err, "failed to create pending task runs for task %d", task.ID)
}
-
- webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Rollout: webhook.NewRollout(plan),
- Project: webhook.NewProject(project),
- TaskRunStatusUpdate: &webhook.EventTaskRunStatusUpdate{
- Title: task.GetDatabaseName(),
- Status: storepb.TaskRun_PENDING.String(),
- },
- })
}
}
return nil
@@ -766,16 +744,6 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, req *connect.Request
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to create pending task runs, error %v", err))
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- Issue: webhook.NewIssue(issueN),
- Project: webhook.NewProject(project),
- Rollout: webhook.NewRollout(plan),
- TaskRunStatusUpdate: &webhook.EventTaskRunStatusUpdate{
- Status: storepb.TaskRun_PENDING.String(),
- },
- })
// Tickle task run scheduler.
s.stateCfg.TaskRunTickleChan <- 0
@@ -867,19 +835,6 @@ func (s *RolloutService) BatchSkipTasks(ctx context.Context, req *connect.Reques
s.stateCfg.TaskSkippedOrDoneChan <- task.ID
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- Comment: request.Reason,
- Issue: webhook.NewIssue(issueN),
- Project: webhook.NewProject(project),
- Rollout: webhook.NewRollout(plan),
- TaskRunStatusUpdate: &webhook.EventTaskRunStatusUpdate{
- Status: storepb.TaskRun_SKIPPED.String(),
- SkippedReason: request.Reason,
- },
- })
-
return connect.NewResponse(&v1pb.BatchSkipTasksResponse{}), nil
}
@@ -985,17 +940,6 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, req *connect.R
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to batch patch task run status to canceled"))
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: user,
- Type: storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- Issue: webhook.NewIssue(issueN),
- Rollout: webhook.NewRollout(plan),
- Project: webhook.NewProject(project),
- TaskRunStatusUpdate: &webhook.EventTaskRunStatusUpdate{
- Status: storepb.TaskRun_CANCELED.String(),
- },
- })
-
return connect.NewResponse(&v1pb.BatchCancelTaskRunsResponse{}), nil
}
diff --git a/backend/component/webhook/event.go b/backend/component/webhook/event.go
index e977292045..bb21cacc88 100644
--- a/backend/component/webhook/event.go
+++ b/backend/component/webhook/event.go
@@ -1,6 +1,8 @@
package webhook
import (
+ "time"
+
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/store"
)
@@ -14,11 +16,12 @@ type Event struct {
Project *Project
Rollout *Rollout
- IssueUpdate *EventIssueUpdate
- IssueApprovalCreate *EventIssueApprovalCreate
- IssueRolloutReady *EventIssueRolloutReady
- StageStatusUpdate *EventStageStatusUpdate
- TaskRunStatusUpdate *EventTaskRunStatusUpdate
+ // Focused event types
+ IssueCreated *EventIssueCreated
+ ApprovalRequested *EventIssueApprovalRequested
+ SentBack *EventIssueSentBack
+ PipelineFailed *EventPipelineFailed
+ PipelineCompleted *EventPipelineCompleted
}
func NewIssue(i *store.IssueMessage) *Issue {
@@ -68,27 +71,45 @@ type Rollout struct {
UID int
}
-type EventIssueUpdate struct {
- Path string
+type EventIssueCreated struct {
+ CreatorName string
+ CreatorEmail string
+}
+
+type EventIssueApprovalRequested struct {
+ ApprovalRole string
+ Approvers []User
+}
+
+type EventIssueSentBack struct {
+ ApproverName string
+ ApproverEmail string
+ CreatorName string
+ CreatorEmail string
+ Reason string
}
-type EventIssueApprovalCreate struct {
- Role string
+type EventPipelineFailed struct {
+ FailedTasks []FailedTask
+ FirstFailureTime time.Time
}
-type EventIssueRolloutReady struct {
- RolloutPolicy *storepb.RolloutPolicy
- StageName string
+type FailedTask struct {
+ TaskID int64
+ TaskName string
+ DatabaseName string
+ InstanceName string
+ ErrorMessage string
+ FailedAt time.Time
}
-type EventStageStatusUpdate struct {
- StageTitle string
- StageID string
+type EventPipelineCompleted struct {
+ TotalTasks int
+ StartedAt time.Time
+ CompletedAt time.Time
}
-type EventTaskRunStatusUpdate struct {
- Title string
- Status string
- Detail string
- SkippedReason string
+type User struct {
+ Name string
+ Email string
}
diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.go
index 059b84852a..af389dcf71 100644
--- a/backend/component/webhook/manager.go
+++ b/backend/component/webhook/manager.go
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log/slog"
- "strings"
"time"
"github.com/gosimple/slug"
@@ -12,35 +11,24 @@ import (
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
- "github.com/bytebase/bytebase/backend/component/iam"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/plugin/webhook"
"github.com/bytebase/bytebase/backend/store"
- "github.com/bytebase/bytebase/backend/utils"
"github.com/pkg/errors"
)
// Manager is the webhook manager.
type Manager struct {
- store *store.Store
- iamManager *iam.Manager
- profile *config.Profile
+ store *store.Store
+ profile *config.Profile
}
-// Metadata is the activity metadata.
-type Metadata struct {
- Issue *store.IssueMessage
-}
-
-type UsersGetter func(ctx context.Context) ([]*store.UserMessage, error)
-
// NewManager creates an activity manager.
-func NewManager(store *store.Store, iamManager *iam.Manager, profile *config.Profile) *Manager {
+func NewManager(store *store.Store, profile *config.Profile) *Manager {
return &Manager{
- store: store,
- iamManager: iamManager,
- profile: profile,
+ store: store,
+ profile: profile,
}
}
@@ -92,130 +80,75 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
link = fmt.Sprintf("%s/projects/%s/plans/%d/rollout", externalURL, e.Project.ResourceID, e.Rollout.UID)
}
switch e.Type {
- case storepb.Activity_ISSUE_CREATE:
+ case storepb.Activity_ISSUE_CREATED:
title = "Issue created"
titleZh = "创建工单"
-
- case storepb.Activity_ISSUE_STATUS_UPDATE:
- switch e.Issue.Status {
- case "OPEN":
- title = "Issue reopened"
- titleZh = "工单重开"
- case "DONE":
- level = webhook.WebhookSuccess
- title = "Issue resolved"
- titleZh = "工单完成"
- case "CANCELED":
- title = "Issue canceled"
- titleZh = "工单取消"
- default:
- title = "Issue status changed"
- titleZh = "工单状态变更"
- }
-
- case storepb.Activity_ISSUE_COMMENT_CREATE:
- title = "Comment created"
- titleZh = "工单新评论"
-
- case storepb.Activity_ISSUE_FIELD_UPDATE:
- update := e.IssueUpdate
- switch update.Path {
- case "description":
- title = "Changed issue description"
- titleZh = "工单描述变更"
- case "title":
- title = "Changed issue name"
- titleZh = "工单标题变更"
- default:
- title = "Updated issue"
- titleZh = "工单信息变更"
- }
-
- case storepb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE:
- u := e.StageStatusUpdate
- if e.Issue != nil {
- stageID := u.StageID
- if stageID == "" {
- stageID = "-" // Use "-" as a placeholder if StageID is not set.
+ if e.IssueCreated != nil {
+ webhookCtx.Description = fmt.Sprintf("%s created issue %s", e.IssueCreated.CreatorName, e.Issue.Title)
+ }
+
+ case storepb.Activity_ISSUE_APPROVAL_REQUESTED:
+ level = webhook.WebhookWarn
+ title = "Approval required"
+ titleZh = "需要审批"
+ if e.ApprovalRequested != nil {
+ webhookCtx.ApprovalRole = e.ApprovalRequested.ApprovalRole
+ mentionUsers = make([]*store.UserMessage, 0, len(e.ApprovalRequested.Approvers))
+ for _, user := range e.ApprovalRequested.Approvers {
+ mentionUsers = append(mentionUsers, &store.UserMessage{
+ Name: user.Name,
+ Email: user.Email,
+ })
}
- link = fmt.Sprintf("%s/projects/%s/issues/%s-%d?stage=%s", setting.ExternalUrl, e.Project.ResourceID, slug.Make(e.Issue.Title), e.Issue.UID, stageID)
}
- title = "Stage ends"
- titleZh = "阶段结束"
- case storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE:
- u := e.TaskRunStatusUpdate
- switch u.Status {
- case storepb.TaskRun_PENDING.String():
- title = "Task run started"
- titleZh = "任务开始"
- case storepb.TaskRun_RUNNING.String():
- title = "Task run is running"
- titleZh = "任务运行中"
- case storepb.TaskRun_DONE.String():
- level = webhook.WebhookSuccess
- title = "Task run completed"
- titleZh = "任务完成"
- case storepb.TaskRun_FAILED.String():
- level = webhook.WebhookError
- title = "Task run failed"
- titleZh = "任务失败"
- case storepb.TaskRun_CANCELED.String():
- title = "Task run is canceled"
- titleZh = "任务取消"
- case storepb.TaskRun_SKIPPED.String():
- title = "Task is skipped"
- titleZh = "任务跳过"
- default:
- title = "Task run status changed"
- titleZh = "任务状态变更"
- }
-
- case storepb.Activity_NOTIFY_ISSUE_APPROVED:
- title = "Issue approved"
- titleZh = "工单审批通过"
- creatorUser, err := m.store.GetUserByEmail(ctx, e.Issue.CreatorEmail)
- if err != nil {
- slog.Warn("failed to get creator user for issue notification",
- slog.String("issue_name", e.Issue.Title),
- log.BBError(err))
- // Continue without mentioning the creator if unable to fetch
- } else {
- mentionUsers = append(mentionUsers, creatorUser)
+ case storepb.Activity_ISSUE_SENT_BACK:
+ level = webhook.WebhookWarn
+ title = "Issue sent back"
+ titleZh = "工单被退回"
+ if e.SentBack != nil {
+ webhookCtx.Description = fmt.Sprintf("%s sent back the issue: %s", e.SentBack.ApproverName, e.SentBack.Reason)
+ mentionUsers = []*store.UserMessage{
+ {
+ Name: e.SentBack.CreatorName,
+ Email: e.SentBack.CreatorEmail,
+ },
+ }
}
- case storepb.Activity_NOTIFY_PIPELINE_ROLLOUT:
- u := e.IssueRolloutReady
- title = "Issue is waiting for rollout"
- titleZh = "工单待发布"
- var usersGetters []UsersGetter
- if u.RolloutPolicy.GetAutomatic() {
- creatorUser, err := m.store.GetUserByEmail(ctx, e.Issue.CreatorEmail)
- if err != nil {
- slog.Warn("failed to get creator user for issue notification",
- slog.String("issue_name", e.Issue.Title),
- log.BBError(err))
- } else {
- usersGetters = append(usersGetters, getUsersFromUsers(creatorUser))
+ case storepb.Activity_PIPELINE_FAILED:
+ level = webhook.WebhookError
+ title = "Pipeline failed"
+ titleZh = "流水线失败"
+ if e.PipelineFailed != nil {
+ failedTasks := make([]webhook.FailedTaskInfo, 0, len(e.PipelineFailed.FailedTasks))
+ for _, task := range e.PipelineFailed.FailedTasks {
+ failedTasks = append(failedTasks, webhook.FailedTaskInfo{
+ Name: task.TaskName,
+ Instance: task.InstanceName,
+ Database: task.DatabaseName,
+ ErrorMessage: task.ErrorMessage,
+ FailedAt: task.FailedAt.Format(time.RFC3339),
+ })
}
- } else {
- for _, role := range u.RolloutPolicy.GetRoles() {
- role := strings.TrimPrefix(role, "roles/")
- usersGetters = append(usersGetters, getUsersFromRole(m.store, role, e.Project.ResourceID))
+ webhookCtx.FailedTasks = failedTasks
+ webhookCtx.Description = fmt.Sprintf("%d task(s) failed", len(failedTasks))
+ }
+
+ case storepb.Activity_PIPELINE_COMPLETED:
+ level = webhook.WebhookSuccess
+ title = "Pipeline completed"
+ titleZh = "流水线完成"
+ if e.PipelineCompleted != nil {
+ duration := e.PipelineCompleted.CompletedAt.Sub(e.PipelineCompleted.StartedAt)
+ webhookCtx.PipelineMetrics = &webhook.PipelineMetrics{
+ TotalTasks: e.PipelineCompleted.TotalTasks,
+ StartedAt: e.PipelineCompleted.StartedAt.Format(time.RFC3339),
+ CompletedAt: e.PipelineCompleted.CompletedAt.Format(time.RFC3339),
+ DurationSecs: int64(duration.Seconds()),
}
+ webhookCtx.Description = fmt.Sprintf("Completed %d task(s) in %s", e.PipelineCompleted.TotalTasks, duration.String())
}
- mentionUsers = getUsersForDirectMessage(ctx, e, usersGetters...)
-
- case storepb.Activity_ISSUE_APPROVAL_NOTIFY:
- roleWithPrefix := e.IssueApprovalCreate.Role
-
- title = "Issue approval needed"
- titleZh = "工单待审批"
-
- var usersGetter UsersGetter
- role := strings.TrimPrefix(roleWithPrefix, "roles/")
- usersGetter = getUsersFromRole(m.store, role, e.Project.ResourceID)
- mentionUsers = getUsersForDirectMessage(ctx, e, usersGetter)
default:
// Unsupported event type
@@ -240,8 +173,6 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
Name: common.FormatProject(e.Project.ResourceID),
Title: e.Project.Title,
},
- Stage: nil,
- TaskResult: nil,
Description: e.Comment,
Link: link,
ActorID: e.Actor.ID,
@@ -276,51 +207,10 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even
UID: e.Rollout.UID,
}
}
- if u := e.TaskRunStatusUpdate; u != nil {
- webhookCtx.TaskResult = &webhook.TaskResult{
- Name: u.Title,
- Status: u.Status,
- Detail: u.Detail,
- SkippedReason: u.SkippedReason,
- }
- }
- if u := e.StageStatusUpdate; u != nil {
- webhookCtx.Stage = &webhook.Stage{
- Name: u.StageTitle,
- }
- }
return &webhookCtx, nil
}
-func getUsersForDirectMessage(ctx context.Context, e *Event, usersGetters ...UsersGetter) []*store.UserMessage {
- mentionedUser := map[int]bool{}
- mentionUsers := []*store.UserMessage{}
-
- for _, usersGetter := range usersGetters {
- users, err := usersGetter(ctx)
- if err != nil {
- slog.Warn("failed to get users",
- slog.String("event", e.Type.String()),
- slog.String("issue_name", e.Issue.Title),
- slog.Int("issue_uid", e.Issue.UID),
- log.BBError(err))
- continue
- }
- for _, user := range users {
- if mentionedUser[user.ID] {
- continue
- }
- if user.MemberDeleted {
- continue
- }
- mentionedUser[user.ID] = true
- mentionUsers = append(mentionUsers, user)
- }
- }
- return mentionUsers
-}
-
func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Context, webhookList []*store.ProjectWebhookMessage) {
ctx = context.WithoutCancel(ctx)
setting, err := m.store.GetAppIMSetting(ctx)
@@ -351,24 +241,3 @@ func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Conte
}(&webhookCtx, hook)
}
}
-
-func getUsersFromRole(s *store.Store, role string, projectID string) UsersGetter {
- return func(ctx context.Context) ([]*store.UserMessage, error) {
- projectIAM, err := s.GetProjectIamPolicy(ctx, projectID)
- if err != nil {
- return nil, err
- }
- workspaceIAM, err := s.GetWorkspaceIamPolicy(ctx)
- if err != nil {
- return nil, err
- }
-
- return utils.GetUsersByRoleInIAMPolicy(ctx, s, role, projectIAM.Policy, workspaceIAM.Policy), nil
- }
-}
-
-func getUsersFromUsers(users ...*store.UserMessage) UsersGetter {
- return func(_ context.Context) ([]*store.UserMessage, error) {
- return users, nil
- }
-}
diff --git a/backend/generated-go/store/project_webhook.pb.go b/backend/generated-go/store/project_webhook.pb.go
index 65d5ae6d78..3861c52d46 100644
--- a/backend/generated-go/store/project_webhook.pb.go
+++ b/backend/generated-go/store/project_webhook.pb.go
@@ -27,55 +27,35 @@ type Activity_Type int32
const (
// Unspecified type.
Activity_TYPE_UNSPECIFIED Activity_Type = 0
- // Issue related activity types.
- //
- // ISSUE_CREATE represents creating an issue.
- Activity_ISSUE_CREATE Activity_Type = 1
- // ISSUE_COMMENT_CREATE represents commenting on an issue.
- Activity_ISSUE_COMMENT_CREATE Activity_Type = 2
- // ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.
- Activity_ISSUE_FIELD_UPDATE Activity_Type = 3
- // ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL for now.
- Activity_ISSUE_STATUS_UPDATE Activity_Type = 4
- // ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.
- Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE Activity_Type = 5
- // ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.
- Activity_ISSUE_APPROVAL_NOTIFY Activity_Type = 6
- // ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.
- Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE Activity_Type = 7
- // Notifications via webhooks.
- //
- // NOTIFY_ISSUE_APPROVED represents the issue approved notification.
- Activity_NOTIFY_ISSUE_APPROVED Activity_Type = 8
- // NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.
- Activity_NOTIFY_PIPELINE_ROLLOUT Activity_Type = 9
+ // ISSUE_CREATED represents a new issue creation event.
+ Activity_ISSUE_CREATED Activity_Type = 10
+ // ISSUE_APPROVAL_REQUESTED represents an approval request event.
+ Activity_ISSUE_APPROVAL_REQUESTED Activity_Type = 11
+ // ISSUE_SENT_BACK represents an issue being sent back by an approver.
+ Activity_ISSUE_SENT_BACK Activity_Type = 12
+ // PIPELINE_FAILED represents a pipeline failure event.
+ Activity_PIPELINE_FAILED Activity_Type = 13
+ // PIPELINE_COMPLETED represents a pipeline completion event.
+ Activity_PIPELINE_COMPLETED Activity_Type = 14
)
// Enum value maps for Activity_Type.
var (
Activity_Type_name = map[int32]string{
- 0: "TYPE_UNSPECIFIED",
- 1: "ISSUE_CREATE",
- 2: "ISSUE_COMMENT_CREATE",
- 3: "ISSUE_FIELD_UPDATE",
- 4: "ISSUE_STATUS_UPDATE",
- 5: "ISSUE_PIPELINE_STAGE_STATUS_UPDATE",
- 6: "ISSUE_APPROVAL_NOTIFY",
- 7: "ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE",
- 8: "NOTIFY_ISSUE_APPROVED",
- 9: "NOTIFY_PIPELINE_ROLLOUT",
+ 0: "TYPE_UNSPECIFIED",
+ 10: "ISSUE_CREATED",
+ 11: "ISSUE_APPROVAL_REQUESTED",
+ 12: "ISSUE_SENT_BACK",
+ 13: "PIPELINE_FAILED",
+ 14: "PIPELINE_COMPLETED",
}
Activity_Type_value = map[string]int32{
- "TYPE_UNSPECIFIED": 0,
- "ISSUE_CREATE": 1,
- "ISSUE_COMMENT_CREATE": 2,
- "ISSUE_FIELD_UPDATE": 3,
- "ISSUE_STATUS_UPDATE": 4,
- "ISSUE_PIPELINE_STAGE_STATUS_UPDATE": 5,
- "ISSUE_APPROVAL_NOTIFY": 6,
- "ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE": 7,
- "NOTIFY_ISSUE_APPROVED": 8,
- "NOTIFY_PIPELINE_ROLLOUT": 9,
+ "TYPE_UNSPECIFIED": 0,
+ "ISSUE_CREATED": 10,
+ "ISSUE_APPROVAL_REQUESTED": 11,
+ "ISSUE_SENT_BACK": 12,
+ "PIPELINE_FAILED": 13,
+ "PIPELINE_COMPLETED": 14,
}
)
@@ -230,19 +210,16 @@ var File_store_project_webhook_proto protoreflect.FileDescriptor
const file_store_project_webhook_proto_rawDesc = "" +
"\n" +
- "\x1bstore/project_webhook.proto\x12\x0ebytebase.store\x1a\x12store/common.proto\"\xac\x02\n" +
- "\bActivity\"\x9f\x02\n" +
+ "\x1bstore/project_webhook.proto\x12\x0ebytebase.store\x1a\x12store/common.proto\"\x9c\x01\n" +
+ "\bActivity\"\x8f\x01\n" +
"\x04Type\x12\x14\n" +
- "\x10TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +
- "\fISSUE_CREATE\x10\x01\x12\x18\n" +
- "\x14ISSUE_COMMENT_CREATE\x10\x02\x12\x16\n" +
- "\x12ISSUE_FIELD_UPDATE\x10\x03\x12\x17\n" +
- "\x13ISSUE_STATUS_UPDATE\x10\x04\x12&\n" +
- "\"ISSUE_PIPELINE_STAGE_STATUS_UPDATE\x10\x05\x12\x19\n" +
- "\x15ISSUE_APPROVAL_NOTIFY\x10\x06\x12)\n" +
- "%ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE\x10\a\x12\x19\n" +
- "\x15NOTIFY_ISSUE_APPROVED\x10\b\x12\x1b\n" +
- "\x17NOTIFY_PIPELINE_ROLLOUT\x10\t\"\xcf\x01\n" +
+ "\x10TYPE_UNSPECIFIED\x10\x00\x12\x11\n" +
+ "\rISSUE_CREATED\x10\n" +
+ "\x12\x1c\n" +
+ "\x18ISSUE_APPROVAL_REQUESTED\x10\v\x12\x13\n" +
+ "\x0fISSUE_SENT_BACK\x10\f\x12\x13\n" +
+ "\x0fPIPELINE_FAILED\x10\r\x12\x16\n" +
+ "\x12PIPELINE_COMPLETED\x10\x0e\"\xcf\x01\n" +
"\x0eProjectWebhook\x12/\n" +
"\x04type\x18\x01 \x01(\x0e2\x1b.bytebase.store.WebhookTypeR\x04type\x12\x14\n" +
"\x05title\x18\x02 \x01(\tR\x05title\x12\x10\n" +
diff --git a/backend/generated-go/v1/project_service.pb.go b/backend/generated-go/v1/project_service.pb.go
index 367f549738..5b0bd39436 100644
--- a/backend/generated-go/v1/project_service.pb.go
+++ b/backend/generated-go/v1/project_service.pb.go
@@ -31,55 +31,35 @@ type Activity_Type int32
const (
// Unspecified type.
Activity_TYPE_UNSPECIFIED Activity_Type = 0
- // Issue related activity types.
- //
- // ISSUE_CREATE represents creating an issue.
- Activity_ISSUE_CREATE Activity_Type = 1
- // ISSUE_COMMENT_CREATE represents commenting on an issue.
- Activity_ISSUE_COMMENT_CREATE Activity_Type = 2
- // ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.
- Activity_ISSUE_FIELD_UPDATE Activity_Type = 3
- // ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL fow now.
- Activity_ISSUE_STATUS_UPDATE Activity_Type = 4
- // ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.
- Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE Activity_Type = 5
- // ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.
- Activity_ISSUE_APPROVAL_NOTIFY Activity_Type = 6
- // ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.
- Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE Activity_Type = 7
- // Notifications via webhooks.
- //
- // NOTIFY_ISSUE_APPROVED represents the issue approved notification.
- Activity_NOTIFY_ISSUE_APPROVED Activity_Type = 8
- // NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.
- Activity_NOTIFY_PIPELINE_ROLLOUT Activity_Type = 9
+ // ISSUE_CREATED represents a new issue creation event.
+ Activity_ISSUE_CREATED Activity_Type = 10
+ // ISSUE_APPROVAL_REQUESTED represents an approval request event.
+ Activity_ISSUE_APPROVAL_REQUESTED Activity_Type = 11
+ // ISSUE_SENT_BACK represents an issue being sent back by an approver.
+ Activity_ISSUE_SENT_BACK Activity_Type = 12
+ // PIPELINE_FAILED represents a pipeline failure event.
+ Activity_PIPELINE_FAILED Activity_Type = 13
+ // PIPELINE_COMPLETED represents a pipeline completion event.
+ Activity_PIPELINE_COMPLETED Activity_Type = 14
)
// Enum value maps for Activity_Type.
var (
Activity_Type_name = map[int32]string{
- 0: "TYPE_UNSPECIFIED",
- 1: "ISSUE_CREATE",
- 2: "ISSUE_COMMENT_CREATE",
- 3: "ISSUE_FIELD_UPDATE",
- 4: "ISSUE_STATUS_UPDATE",
- 5: "ISSUE_PIPELINE_STAGE_STATUS_UPDATE",
- 6: "ISSUE_APPROVAL_NOTIFY",
- 7: "ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE",
- 8: "NOTIFY_ISSUE_APPROVED",
- 9: "NOTIFY_PIPELINE_ROLLOUT",
+ 0: "TYPE_UNSPECIFIED",
+ 10: "ISSUE_CREATED",
+ 11: "ISSUE_APPROVAL_REQUESTED",
+ 12: "ISSUE_SENT_BACK",
+ 13: "PIPELINE_FAILED",
+ 14: "PIPELINE_COMPLETED",
}
Activity_Type_value = map[string]int32{
- "TYPE_UNSPECIFIED": 0,
- "ISSUE_CREATE": 1,
- "ISSUE_COMMENT_CREATE": 2,
- "ISSUE_FIELD_UPDATE": 3,
- "ISSUE_STATUS_UPDATE": 4,
- "ISSUE_PIPELINE_STAGE_STATUS_UPDATE": 5,
- "ISSUE_APPROVAL_NOTIFY": 6,
- "ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE": 7,
- "NOTIFY_ISSUE_APPROVED": 8,
- "NOTIFY_PIPELINE_ROLLOUT": 9,
+ "TYPE_UNSPECIFIED": 0,
+ "ISSUE_CREATED": 10,
+ "ISSUE_APPROVAL_REQUESTED": 11,
+ "ISSUE_SENT_BACK": 12,
+ "PIPELINE_FAILED": 13,
+ "PIPELINE_COMPLETED": 14,
}
)
@@ -1426,15 +1406,11 @@ type Webhook struct {
// notification_types is the list of activities types that the webhook is interested in.
// Bytebase will only send notifications to the webhook if the activity type is in the list.
// It should not be empty, and should be a subset of the following:
- // - ISSUE_CREATE
- // - ISSUE_COMMENT_CREATE
- // - ISSUE_FIELD_UPDATE
- // - ISSUE_STATUS_UPDATE
- // - ISSUE_APPROVAL_NOTIFY
- // - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- // - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- // - NOTIFY_ISSUE_APPROVED
- // - NOTIFY_PIPELINE_ROLLOUT
+ // - ISSUE_CREATED
+ // - ISSUE_APPROVAL_REQUESTED
+ // - ISSUE_SENT_BACK
+ // - PIPELINE_FAILED
+ // - PIPELINE_COMPLETED
NotificationTypes []Activity_Type `protobuf:"varint,5,rep,packed,name=notification_types,json=notificationTypes,proto3,enum=bytebase.v1.Activity_Type" json:"notification_types,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -1704,19 +1680,16 @@ const file_v1_project_service_proto_rawDesc = "" +
"\x03url\x18\x04 \x01(\tB\x03\xe0A\x02R\x03url\x12%\n" +
"\x0edirect_message\x18\x06 \x01(\bR\rdirectMessage\x12N\n" +
"\x12notification_types\x18\x05 \x03(\x0e2\x1a.bytebase.v1.Activity.TypeB\x03\xe0A\x06R\x11notificationTypes:@\xeaA=\n" +
- "\x14bytebase.com/Webhook\x12%projects/{project}/webhooks/{webhook}\"\xac\x02\n" +
- "\bActivity\"\x9f\x02\n" +
+ "\x14bytebase.com/Webhook\x12%projects/{project}/webhooks/{webhook}\"\x9c\x01\n" +
+ "\bActivity\"\x8f\x01\n" +
"\x04Type\x12\x14\n" +
- "\x10TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +
- "\fISSUE_CREATE\x10\x01\x12\x18\n" +
- "\x14ISSUE_COMMENT_CREATE\x10\x02\x12\x16\n" +
- "\x12ISSUE_FIELD_UPDATE\x10\x03\x12\x17\n" +
- "\x13ISSUE_STATUS_UPDATE\x10\x04\x12&\n" +
- "\"ISSUE_PIPELINE_STAGE_STATUS_UPDATE\x10\x05\x12\x19\n" +
- "\x15ISSUE_APPROVAL_NOTIFY\x10\x06\x12)\n" +
- "%ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE\x10\a\x12\x19\n" +
- "\x15NOTIFY_ISSUE_APPROVED\x10\b\x12\x1b\n" +
- "\x17NOTIFY_PIPELINE_ROLLOUT\x10\t2\x82\x12\n" +
+ "\x10TYPE_UNSPECIFIED\x10\x00\x12\x11\n" +
+ "\rISSUE_CREATED\x10\n" +
+ "\x12\x1c\n" +
+ "\x18ISSUE_APPROVAL_REQUESTED\x10\v\x12\x13\n" +
+ "\x0fISSUE_SENT_BACK\x10\f\x12\x13\n" +
+ "\x0fPIPELINE_FAILED\x10\r\x12\x16\n" +
+ "\x12PIPELINE_COMPLETED\x10\x0e2\x82\x12\n" +
"\x0eProjectService\x12\x7f\n" +
"\n" +
"GetProject\x12\x1e.bytebase.v1.GetProjectRequest\x1a\x14.bytebase.v1.Project\";\xdaA\x04name\x8a\xea0\x0fbb.projects.get\x90\xea0\x01\x82\xd3\xe4\x93\x02\x17\x12\x15/v1/{name=projects/*}\x12\x95\x01\n" +
diff --git a/backend/migrator/migration/3.14/0014##clean_deprecated_webhook_activities.sql b/backend/migrator/migration/3.14/0014##clean_deprecated_webhook_activities.sql
new file mode 100644
index 0000000000..477024ce20
--- /dev/null
+++ b/backend/migrator/migration/3.14/0014##clean_deprecated_webhook_activities.sql
@@ -0,0 +1,36 @@
+-- Migrate deprecated webhook activity types to new focused event types
+-- Mappings:
+-- ISSUE_CREATE → ISSUE_CREATED
+-- ISSUE_APPROVAL_NOTIFY → ISSUE_APPROVAL_REQUESTED
+-- ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE → PIPELINE_FAILED
+-- ISSUE_PIPELINE_STAGE_STATUS_UPDATE → PIPELINE_COMPLETED
+-- Removed (no mapping):
+-- ISSUE_COMMENT_CREATE, ISSUE_FIELD_UPDATE, ISSUE_STATUS_UPDATE,
+-- NOTIFY_ISSUE_APPROVED, NOTIFY_PIPELINE_ROLLOUT
+UPDATE project_webhook
+SET payload = jsonb_set(
+ payload,
+ '{activities}',
+ (
+ SELECT COALESCE(jsonb_agg(DISTINCT mapped_activity), '[]'::jsonb)
+ FROM (
+ SELECT
+ CASE activity
+ WHEN 'ISSUE_CREATE' THEN 'ISSUE_CREATED'
+ WHEN 'ISSUE_APPROVAL_NOTIFY' THEN 'ISSUE_APPROVAL_REQUESTED'
+ WHEN 'ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE' THEN 'PIPELINE_FAILED'
+ WHEN 'ISSUE_PIPELINE_STAGE_STATUS_UPDATE' THEN 'PIPELINE_COMPLETED'
+ ELSE activity
+ END AS mapped_activity
+ FROM jsonb_array_elements_text(payload->'activities') AS activity
+ WHERE activity NOT IN (
+ 'ISSUE_COMMENT_CREATE',
+ 'ISSUE_FIELD_UPDATE',
+ 'ISSUE_STATUS_UPDATE',
+ 'NOTIFY_ISSUE_APPROVED',
+ 'NOTIFY_PIPELINE_ROLLOUT'
+ )
+ ) AS mapped
+ )
+)
+WHERE payload ? 'activities';
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index b95dbff4ac..22ca5000cd 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -12,8 +12,8 @@ import (
func TestLatestVersion(t *testing.T) {
files, err := getSortedVersionedFiles()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("3.14.13"), *files[len(files)-1].version)
- require.Equal(t, "migration/3.14/0013##rename_token_duration_setting.sql", files[len(files)-1].path)
+ require.Equal(t, semver.MustParse("3.14.14"), *files[len(files)-1].version)
+ require.Equal(t, "migration/3.14/0014##clean_deprecated_webhook_activities.sql", files[len(files)-1].path)
}
func TestVersionUnique(t *testing.T) {
diff --git a/backend/plugin/webhook/webhook.go b/backend/plugin/webhook/webhook.go
index e03b5861ee..9e867a6015 100644
--- a/backend/plugin/webhook/webhook.go
+++ b/backend/plugin/webhook/webhook.go
@@ -104,6 +104,28 @@ type Context struct {
DirectMessage bool
IMSetting *storepb.AppIMSetting
+
+ // New event data
+ ApprovalRole string
+ FailedTasks []FailedTaskInfo
+ PipelineMetrics *PipelineMetrics
+}
+
+// FailedTaskInfo contains information about a failed task.
+type FailedTaskInfo struct {
+ Name string
+ Instance string
+ Database string
+ ErrorMessage string
+ FailedAt string
+}
+
+// PipelineMetrics contains metrics about a pipeline execution.
+type PipelineMetrics struct {
+ TotalTasks int
+ StartedAt string
+ CompletedAt string
+ DurationSecs int64
}
// Receiver is the webhook receiver.
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 24918f5f2d..acc7edc723 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -212,13 +212,6 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
return errors.Wrapf(err, "failed to create issue comment after changing the issue status")
}
- r.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(updatedIssue),
- Project: webhook.NewProject(project),
- })
return nil
}(); err != nil {
return false, errors.Wrap(err, "failed to update issue status")
@@ -240,46 +233,6 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
return false, errors.Wrap(err, "failed to update issue payload")
}
- if err := func() error {
- if payload.Approval.ApprovalTemplate != nil {
- return nil
- }
- if issue.PlanUID == nil {
- return nil
- }
- tasks, err := r.store.ListTasks(ctx, &store.TaskFind{PlanID: issue.PlanUID})
- if err != nil {
- return errors.Wrapf(err, "failed to list tasks")
- }
- if len(tasks) == 0 {
- return nil
- }
- // Get the first environment from tasks
- var firstEnvironment string
- for _, task := range tasks {
- firstEnvironment = task.Environment
- break
- }
- policy, err := apiv1.GetValidRolloutPolicyForEnvironment(ctx, r.store, firstEnvironment)
- if err != nil {
- return err
- }
- r.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_NOTIFY_PIPELINE_ROLLOUT,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Project: webhook.NewProject(project),
- IssueRolloutReady: &webhook.EventIssueRolloutReady{
- RolloutPolicy: policy,
- StageName: firstEnvironment,
- },
- })
- return nil
- }(); err != nil {
- slog.Error("failed to create rollout release notification activity", log.BBError(err))
- }
-
func() {
if payload.Approval.ApprovalTemplate == nil {
return
@@ -288,14 +241,31 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
if role == "" {
return
}
+
+ // Get issue creator as actor
+ creator, err := r.store.GetUserByEmail(ctx, issue.CreatorEmail)
+ if err != nil {
+ slog.Warn("failed to get issue creator, using system bot", log.BBError(err))
+ creator = store.SystemBotUser
+ }
+
+ // Get approvers for this role
+ approvers, err := r.getApproversForRole(ctx, issue.ProjectID, role)
+ if err != nil {
+ slog.Warn("failed to get approvers", log.BBError(err))
+ approvers = []webhook.User{} // Continue with empty list
+ }
+
+ // Trigger ISSUE_APPROVAL_REQUESTED webhook
r.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_APPROVAL_NOTIFY,
+ Actor: creator,
+ Type: storepb.Activity_ISSUE_APPROVAL_REQUESTED,
Comment: "",
Issue: webhook.NewIssue(issue),
Project: webhook.NewProject(project),
- IssueApprovalCreate: &webhook.EventIssueApprovalCreate{
- Role: role,
+ ApprovalRequested: &webhook.EventIssueApprovalRequested{
+ ApprovalRole: role,
+ Approvers: approvers,
},
})
}()
@@ -860,3 +830,38 @@ func collectStatementTypes(celVarsList []map[string]any) []string {
}
return result
}
+
+// getApproversForRole retrieves the list of users who have the specified role
+// for the given project. It queries both project and workspace IAM policies.
+// Only returns END_USER type principals (excludes service accounts, system bots, etc).
+func (r *Runner) getApproversForRole(ctx context.Context, projectID string, role string) ([]webhook.User, error) {
+ // Get project IAM policy
+ projectIAM, err := r.store.GetProjectIamPolicy(ctx, projectID)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to get project IAM policy")
+ }
+
+ // Get workspace IAM policy
+ workspaceIAM, err := r.store.GetWorkspaceIamPolicy(ctx)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to get workspace IAM policy")
+ }
+
+ // Get all users with the specified role
+ users := utils.GetUsersByRoleInIAMPolicy(ctx, r.store, role, projectIAM.Policy, workspaceIAM.Policy)
+
+ // Convert to webhook.User format, filtering by END_USER principal type
+ approvers := make([]webhook.User, 0, len(users))
+ for _, user := range users {
+ // Only include END_USER principals as approvers
+ if user.Type != storepb.PrincipalType_END_USER {
+ continue
+ }
+ approvers = append(approvers, webhook.User{
+ Name: user.Name,
+ Email: user.Email,
+ })
+ }
+
+ return approvers, nil
+}
diff --git a/backend/runner/taskrun/pipeline_events.go b/backend/runner/taskrun/pipeline_events.go
new file mode 100644
index 0000000000..25e4b697dd
--- /dev/null
+++ b/backend/runner/taskrun/pipeline_events.go
@@ -0,0 +1,78 @@
+package taskrun
+
+import (
+ "sync"
+ "time"
+
+ "github.com/bytebase/bytebase/backend/component/webhook"
+)
+
+// PipelineFailureWindow tracks failed tasks for aggregation.
+type PipelineFailureWindow struct {
+ firstFailureTime time.Time
+ failedTasks []webhook.FailedTask
+ notificationSent bool
+ timer *time.Timer
+}
+
+// PipelineEventsTracker manages failure aggregation windows per plan.
+type PipelineEventsTracker struct {
+ mu sync.RWMutex
+ windows map[int64]*PipelineFailureWindow // planID -> window
+}
+
+// NewPipelineEventsTracker creates a new pipeline events tracker.
+func NewPipelineEventsTracker() *PipelineEventsTracker {
+ return &PipelineEventsTracker{
+ windows: make(map[int64]*PipelineFailureWindow),
+ }
+}
+
+// RecordTaskFailure adds a failed task to the aggregation window.
+func (t *PipelineEventsTracker) RecordTaskFailure(planID int64, task webhook.FailedTask, onAggregated func([]webhook.FailedTask)) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ window, exists := t.windows[planID]
+ if !exists || window.notificationSent {
+ // Start new window
+ window = &PipelineFailureWindow{
+ firstFailureTime: time.Now(),
+ failedTasks: []webhook.FailedTask{task},
+ notificationSent: false,
+ }
+ t.windows[planID] = window
+
+ // Set 5-minute timer
+ window.timer = time.AfterFunc(5*time.Minute, func() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ if w, ok := t.windows[planID]; ok && !w.notificationSent {
+ w.notificationSent = true
+ // Copy tasks to avoid holding lock during callback
+ tasksCopy := make([]webhook.FailedTask, len(w.failedTasks))
+ copy(tasksCopy, w.failedTasks)
+ // Delete window after sending to prevent memory leak
+ delete(t.windows, planID)
+ onAggregated(tasksCopy)
+ }
+ })
+ } else {
+ // Add to existing window
+ window.failedTasks = append(window.failedTasks, task)
+ }
+}
+
+// Clear removes the window for a plan (call after pipeline completes).
+func (t *PipelineEventsTracker) Clear(planID int64) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ if window, exists := t.windows[planID]; exists {
+ if window.timer != nil {
+ window.timer.Stop()
+ }
+ delete(t.windows, planID)
+ }
+}
diff --git a/backend/runner/taskrun/rollout_creator.go b/backend/runner/taskrun/rollout_creator.go
index fe639332b3..c9524b3136 100644
--- a/backend/runner/taskrun/rollout_creator.go
+++ b/backend/runner/taskrun/rollout_creator.go
@@ -141,7 +141,7 @@ func (rc *RolloutCreator) tryCreateRollout(ctx context.Context, planID int64) {
slog.Info("auto-creating rollout", slog.Int("plan_id", int(planID)))
// Create rollout and pending tasks
- if err := apiv1.CreateRolloutAndPendingTasks(ctx, rc.store, rc.webhookManager, plan, issue, project, nil); err != nil {
+ if err := apiv1.CreateRolloutAndPendingTasks(ctx, rc.store, plan, issue, project, nil); err != nil {
slog.Error("failed to create rollout and pending tasks",
slog.Int("plan_id", int(planID)),
log.BBError(err))
diff --git a/backend/runner/taskrun/running_scheduler.go b/backend/runner/taskrun/running_scheduler.go
index 6f6db6ea4b..26a759a892 100644
--- a/backend/runner/taskrun/running_scheduler.go
+++ b/backend/runner/taskrun/running_scheduler.go
@@ -130,6 +130,9 @@ func (s *Scheduler) scheduleRunningTaskRun(ctx context.Context, taskRun *store.T
if err != nil {
return errors.Wrapf(err, "failed to get instance")
}
+ if instance == nil {
+ return errors.Errorf("instance %v not found", task.InstanceID)
+ }
if instance.Deleted {
return errors.Errorf("instance %v is deleted", task.InstanceID)
}
@@ -321,6 +324,7 @@ func (s *Scheduler) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunMe
return
}
s.createActivityForTaskRunStatusUpdate(ctx, task, storepb.TaskRun_FAILED, taskRunResult.Detail)
+ s.recordPipelineFailure(ctx, task, taskRunResult.Detail)
return
case done && err == nil:
@@ -364,7 +368,11 @@ func (s *Scheduler) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunMe
}
}
-func (s *Scheduler) createActivityForTaskRunStatusUpdate(ctx context.Context, task *store.TaskMessage, newStatus storepb.TaskRun_Status, errDetail string) {
+func (*Scheduler) createActivityForTaskRunStatusUpdate(_ context.Context, _ *store.TaskMessage, _ storepb.TaskRun_Status, _ string) {
+ // No webhook events for task run status updates
+}
+
+func (s *Scheduler) recordPipelineFailure(ctx context.Context, task *store.TaskMessage, errDetail string) {
if err := func() error {
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{UID: &task.PlanID})
if err != nil {
@@ -373,6 +381,7 @@ func (s *Scheduler) createActivityForTaskRunStatusUpdate(ctx context.Context, ta
if plan == nil {
return errors.Errorf("plan %v not found", task.PlanID)
}
+
project, err := s.store.GetProject(ctx, &store.FindProjectMessage{ResourceID: &plan.ProjectID})
if err != nil {
return errors.Wrapf(err, "failed to get project")
@@ -380,28 +389,56 @@ func (s *Scheduler) createActivityForTaskRunStatusUpdate(ctx context.Context, ta
if project == nil {
return errors.Errorf("project %v not found", plan.ProjectID)
}
- issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
- PlanUID: &task.PlanID,
- })
+
+ issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{PlanUID: &task.PlanID})
if err != nil {
return errors.Wrap(err, "failed to get issue")
}
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(issue),
- Rollout: webhook.NewRollout(plan),
- Project: webhook.NewProject(project),
- TaskRunStatusUpdate: &webhook.EventTaskRunStatusUpdate{
- Title: task.GetDatabaseName(),
- Status: newStatus.String(),
- Detail: errDetail,
+
+ instance, err := s.store.GetInstance(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
+ if err != nil {
+ return errors.Wrapf(err, "failed to get instance")
+ }
+
+ failedTask := webhook.FailedTask{
+ TaskID: int64(task.ID),
+ TaskName: task.Type.String(),
+ DatabaseName: task.GetDatabaseName(),
+ InstanceName: instance.Metadata.Title,
+ ErrorMessage: errDetail,
+ FailedAt: time.Now(),
+ }
+
+ s.pipelineEvents.RecordTaskFailure(
+ plan.UID,
+ failedTask,
+ func(failedTasks []webhook.FailedTask) {
+ firstFailureTime := time.Now().Add(-5 * time.Minute)
+ if len(failedTasks) > 0 {
+ firstFailureTime = failedTasks[0].FailedAt
+ }
+
+ // Use background context to avoid cancellation issues
+ webhookCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+
+ s.webhookManager.CreateEvent(webhookCtx, &webhook.Event{
+ Actor: store.SystemBotUser,
+ Type: storepb.Activity_PIPELINE_FAILED,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ Rollout: webhook.NewRollout(plan),
+ PipelineFailed: &webhook.EventPipelineFailed{
+ FailedTasks: failedTasks,
+ FirstFailureTime: firstFailureTime,
+ },
+ })
},
- })
+ )
+
return nil
}(); err != nil {
- slog.Error("failed to create activity for task run status update", log.BBError(err))
+ slog.Error("failed to record pipeline failure", log.BBError(err))
}
}
diff --git a/backend/runner/taskrun/scheduler.go b/backend/runner/taskrun/scheduler.go
index 976f0d8751..eb288cf155 100644
--- a/backend/runner/taskrun/scheduler.go
+++ b/backend/runner/taskrun/scheduler.go
@@ -31,6 +31,7 @@ type Scheduler struct {
webhookManager *webhook.Manager
executorMap map[storepb.Task_Type]Executor
profile *config.Profile
+ pipelineEvents *PipelineEventsTracker
}
// NewScheduler will create a new scheduler.
@@ -46,6 +47,7 @@ func NewScheduler(
webhookManager: webhookManager,
profile: profile,
executorMap: map[storepb.Task_Type]Executor{},
+ pipelineEvents: NewPipelineEventsTracker(),
}
}
@@ -64,7 +66,7 @@ func (s *Scheduler) Register(taskType storepb.Task_Type, executorGetter Executor
func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
- go s.ListenTaskSkippedOrDone(ctx)
+ go s.runTaskCompletionListener(ctx)
// Start rollout creator component
rolloutCreator := NewRolloutCreator(s.store, s.stateCfg, s.webhookManager)
@@ -77,22 +79,17 @@ func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
<-ctx.Done()
}
-func (s *Scheduler) ListenTaskSkippedOrDone(ctx context.Context) {
+func (s *Scheduler) runTaskCompletionListener(ctx context.Context) {
defer func() {
if r := recover(); r != nil {
err, ok := r.(error)
if !ok {
err = errors.Errorf("%v", r)
}
- slog.Error("ListenTaskSkippedOrDone PANIC RECOVER", log.BBError(err), log.BBStack("panic-stack"))
+ slog.Error("runTaskCompletionListener PANIC RECOVER", log.BBError(err), log.BBStack("panic-stack"))
}
}()
- slog.Info("TaskSkippedOrDoneListener started")
- type planEnvironment struct {
- planUID int64
- environment string
- }
- planEnvironmentDoneConfirmed := map[planEnvironment]bool{}
+ slog.Info("Task completion listener started")
for {
select {
@@ -102,123 +99,13 @@ func (s *Scheduler) ListenTaskSkippedOrDone(ctx context.Context) {
if err != nil {
return errors.Wrapf(err, "failed to get task")
}
- if planEnvironmentDoneConfirmed[planEnvironment{planUID: task.PlanID, environment: task.Environment}] {
- return nil
- }
-
- environmentTasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &task.PlanID, Environment: &task.Environment})
- if err != nil {
- return errors.Wrapf(err, "failed to list tasks")
- }
-
- skippedOrDone := tasksSkippedOrDone(environmentTasks)
- if !skippedOrDone {
- return nil
- }
-
- planEnvironmentDoneConfirmed[planEnvironment{planUID: task.PlanID, environment: task.Environment}] = true
-
- // Get live environment order
- // Some environments may have zero tasks. We need to filter them out.
- environments, err := s.store.GetEnvironment(ctx)
- if err != nil {
- return errors.Wrapf(err, "failed to get environments")
- }
- var environmentOrder []string
- for _, env := range environments.GetEnvironments() {
- environmentOrder = append(environmentOrder, env.Id)
- }
-
- allTasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &task.PlanID})
- if err != nil {
- return errors.Wrapf(err, "failed to list tasks")
- }
- allTaskEnvironments := map[string]bool{}
- for _, task := range allTasks {
- allTaskEnvironments[task.Environment] = true
- }
-
- // Filter out environments that have zero tasks
- filteredEnvironmentOrder := []string{}
- for _, env := range environmentOrder {
- if allTaskEnvironments[env] {
- filteredEnvironmentOrder = append(filteredEnvironmentOrder, env)
- }
- }
-
- currentEnvironment := task.Environment
- var nextEnvironment string
- for i, env := range filteredEnvironmentOrder {
- if env == currentEnvironment {
- if i < len(filteredEnvironmentOrder)-1 {
- nextEnvironment = filteredEnvironmentOrder[i+1]
- }
- break
- }
- }
-
- plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{UID: &task.PlanID})
- if err != nil {
- return errors.Wrapf(err, "failed to get plan")
- }
- if plan == nil {
- return errors.Errorf("plan %v not found", task.PlanID)
- }
- project, err := s.store.GetProject(ctx, &store.FindProjectMessage{ResourceID: &plan.ProjectID})
- if err != nil {
- return errors.Wrapf(err, "failed to get project")
- }
- if project == nil {
- return errors.Errorf("project %v not found", plan.ProjectID)
- }
- issueN, err := s.store.GetIssue(ctx, &store.FindIssueMessage{PlanUID: &task.PlanID})
- if err != nil {
- return errors.Wrapf(err, "failed to get issue")
- }
- // every task in the stage terminated
- // create "stage ends" activity.
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_ISSUE_PIPELINE_STAGE_STATUS_UPDATE,
- Comment: "",
- Issue: webhook.NewIssue(issueN),
- Rollout: webhook.NewRollout(plan),
- Project: webhook.NewProject(project),
- StageStatusUpdate: &webhook.EventStageStatusUpdate{
- StageTitle: currentEnvironment,
- StageID: currentEnvironment,
- },
- })
-
- // create "notify pipeline rollout" activity.
- if err := func() error {
- if nextEnvironment == "" {
- return nil
- }
- policy, err := s.store.GetRolloutPolicy(ctx, nextEnvironment)
- if err != nil {
- return errors.Wrapf(err, "failed to get rollout policy")
- }
- s.webhookManager.CreateEvent(ctx, &webhook.Event{
- Actor: store.SystemBotUser,
- Type: storepb.Activity_NOTIFY_PIPELINE_ROLLOUT,
- Comment: "",
- Issue: webhook.NewIssue(issueN),
- Project: webhook.NewProject(project),
- IssueRolloutReady: &webhook.EventIssueRolloutReady{
- RolloutPolicy: policy,
- StageName: nextEnvironment,
- },
- })
- return nil
- }(); err != nil {
- slog.Error("failed to create rollout release notification activity", log.BBError(err))
- }
+ // Check if entire plan is complete and handle webhooks
+ s.checkPlanCompletion(ctx, task.PlanID)
return nil
}(); err != nil {
- slog.Error("failed to handle task skipped or done", log.BBError(err))
+ slog.Error("failed to handle task completion", log.BBError(err))
}
case <-ctx.Done():
return
@@ -226,13 +113,117 @@ func (s *Scheduler) ListenTaskSkippedOrDone(ctx context.Context) {
}
}
-func tasksSkippedOrDone(tasks []*store.TaskMessage) bool {
+func (s *Scheduler) checkPlanCompletion(ctx context.Context, planID int64) {
+ // Get all tasks for this plan
+ tasks, err := s.store.ListTasks(ctx, &store.TaskFind{PlanID: &planID})
+ if err != nil {
+ slog.Error("failed to list tasks for plan completion check", log.BBError(err))
+ return
+ }
+
+ // Check if all tasks are in terminal state
+ allComplete := true
+ hasFailures := false
+ var earliestStart, latestEnd *time.Time
+
for _, task := range tasks {
- skipped := task.Payload.GetSkipped()
- done := task.LatestTaskRunStatus == storepb.TaskRun_DONE
- if !skipped && !done {
- return false
+ status := task.LatestTaskRunStatus
+
+ // Check if task is in terminal state
+ isTerminal := status == storepb.TaskRun_DONE ||
+ status == storepb.TaskRun_FAILED ||
+ status == storepb.TaskRun_CANCELED ||
+ status == storepb.TaskRun_SKIPPED ||
+ task.Payload.GetSkipped()
+
+ if !isTerminal {
+ allComplete = false
+ break
+ }
+
+ // Track failures (excluding skipped tasks)
+ if status == storepb.TaskRun_FAILED && !task.Payload.GetSkipped() {
+ hasFailures = true
+ }
+
+ // Track start/end times for metrics
+ if task.RunAt != nil {
+ if earliestStart == nil || task.RunAt.Before(*earliestStart) {
+ earliestStart = task.RunAt
+ }
+ }
+ if task.UpdatedAt != nil {
+ if latestEnd == nil || task.UpdatedAt.After(*latestEnd) {
+ latestEnd = task.UpdatedAt
+ }
}
}
- return true
+
+ // Not all tasks complete yet
+ if !allComplete {
+ return
+ }
+
+ // Always clear the failure window when plan completes
+ s.pipelineEvents.Clear(planID)
+
+ // Only send completion webhook if there were no failures
+ if hasFailures {
+ return
+ }
+
+ // Get plan, project and issue for webhook
+ plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{UID: &planID})
+ if err != nil {
+ slog.Error("failed to get plan for completion webhook", log.BBError(err))
+ return
+ }
+ if plan == nil {
+ slog.Error("plan not found for completion webhook", slog.Int64("plan_id", planID))
+ return
+ }
+
+ project, err := s.store.GetProject(ctx, &store.FindProjectMessage{ResourceID: &plan.ProjectID})
+ if err != nil {
+ slog.Error("failed to get project for completion webhook", log.BBError(err))
+ return
+ }
+ if project == nil {
+ slog.Error("project not found for completion webhook", slog.String("project_id", plan.ProjectID))
+ return
+ }
+
+ issueN, err := s.store.GetIssue(ctx, &store.FindIssueMessage{PlanUID: &planID})
+ if err != nil {
+ slog.Error("failed to get issue for completion webhook", log.BBError(err))
+ return
+ }
+ if issueN == nil {
+ slog.Error("issue not found for completion webhook", slog.Int64("plan_id", planID))
+ return
+ }
+
+ // Send PIPELINE_COMPLETED webhook
+ startedAt := time.Now()
+ completedAt := time.Now()
+ if earliestStart != nil {
+ startedAt = *earliestStart
+ }
+ if latestEnd != nil {
+ completedAt = *latestEnd
+ }
+
+ s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: store.SystemBotUser,
+ Type: storepb.Activity_PIPELINE_COMPLETED,
+ Comment: "",
+ Issue: webhook.NewIssue(issueN),
+ Rollout: webhook.NewRollout(plan),
+ Project: webhook.NewProject(project),
+ PipelineCompleted: &webhook.EventPipelineCompleted{
+ TotalTasks: len(tasks),
+ StartedAt: startedAt,
+ CompletedAt: completedAt,
+ },
+ })
}
diff --git a/backend/server/server.go b/backend/server/server.go
index 554afb1393..90b2771c16 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -178,7 +178,7 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
if err != nil {
return nil, errors.Wrapf(err, "failed to create iam manager")
}
- s.webhookManager = webhook.NewManager(stores, s.iamManager, profile)
+ s.webhookManager = webhook.NewManager(stores, profile)
s.dbFactory = dbfactory.New(s.store, s.licenseService)
// Configure echo server.
diff --git a/backend/tests/webhook_test.go b/backend/tests/webhook_test.go
index a0b68b58fc..ef883d3621 100644
--- a/backend/tests/webhook_test.go
+++ b/backend/tests/webhook_test.go
@@ -146,9 +146,7 @@ func TestWebhookIntegration(t *testing.T) {
// Create webhooks for issue events
for _, eventType := range []v1pb.Activity_Type{
- v1pb.Activity_ISSUE_CREATE,
- v1pb.Activity_ISSUE_STATUS_UPDATE,
- v1pb.Activity_ISSUE_COMMENT_CREATE,
+ v1pb.Activity_ISSUE_CREATED,
} {
_, err := ctl.projectServiceClient.AddWebhook(ctx, connect.NewRequest(&v1pb.AddWebhookRequest{
Project: ctl.project.Name,
diff --git a/docs/plans/2025-12-30-webhook-events-redesign-impl.md b/docs/plans/2025-12-30-webhook-events-redesign-impl.md
new file mode 100644
index 0000000000..8cde69a0e2
--- /dev/null
+++ b/docs/plans/2025-12-30-webhook-events-redesign-impl.md
@@ -0,0 +1,1329 @@
+# Webhook Events Redesign Implementation Plan
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** Redesign webhook notification system to reduce noise and improve signal quality with 5 focused event types
+
+**Architecture:** Add new Activity.Type proto enums, create new event structs in component layer, update plugins to handle new event types, implement pipeline failure aggregation with 5-minute debouncing
+
+**Tech Stack:** Go, Protocol Buffers, existing webhook plugin architecture
+
+---
+
+## Phase 1: Proto Changes
+
+### Task 1: Add New Activity Types to Proto
+
+**Files:**
+- Modify: `proto/store/store/project_webhook.proto:12-37`
+
+**Step 1: Add new activity type enums**
+
+Edit `proto/store/store/project_webhook.proto`, add after line 36:
+
+```proto
+ // New focused event types
+ ISSUE_CREATED = 10;
+ ISSUE_APPROVAL_REQUESTED = 11;
+ ISSUE_SENT_BACK = 12;
+ PIPELINE_FAILED = 13;
+ PIPELINE_COMPLETED = 14;
+```
+
+**Step 2: Format proto files**
+
+Run: `buf format -w proto`
+Expected: Files formatted successfully
+
+**Step 3: Generate Go code from protos**
+
+Run: `cd proto && buf generate`
+Expected: Generated files updated in `backend/generated-go/store/`
+
+**Step 4: Verify generated code**
+
+Run: `grep -A 2 "Activity_ISSUE_CREATED" backend/generated-go/store/project_webhook.pb.go`
+Expected: Find the new constants defined
+
+**Step 5: Commit proto changes**
+
+```bash
+git add proto/store/store/project_webhook.proto backend/generated-go/
+git commit -m "feat: add new webhook activity types
+
+Add 5 new focused activity types:
+- ISSUE_CREATED (10)
+- ISSUE_APPROVAL_REQUESTED (11)
+- ISSUE_SENT_BACK (12)
+- PIPELINE_FAILED (13)
+- PIPELINE_COMPLETED (14)
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 2: Component Layer - Event Data Structures
+
+### Task 2: Create New Event Structs
+
+**Files:**
+- Modify: `backend/component/webhook/event.go:1-95`
+
+**Step 1: Add new event structs to event.go**
+
+Add after the existing `EventTaskRunStatusUpdate` struct (around line 94):
+
+```go
+type EventIssueCreated struct {
+ CreatorName string
+ CreatorEmail string
+}
+
+type EventIssueApprovalRequested struct {
+ ApprovalRole string
+ RequiredCount int
+ Approvers []User
+}
+
+type EventIssueSentBack struct {
+ ApproverName string
+ ApproverEmail string
+ Reason string
+}
+
+type EventPipelineFailed struct {
+ FailedTasks []FailedTask
+ FirstFailureTime time.Time
+}
+
+type FailedTask struct {
+ TaskID int64
+ TaskName string
+ DatabaseName string
+ InstanceName string
+ ErrorMessage string
+ FailedAt time.Time
+}
+
+type EventPipelineCompleted struct {
+ TotalTasks int
+ StartedAt time.Time
+ CompletedAt time.Time
+}
+
+type User struct {
+ Name string
+ Email string
+}
+```
+
+**Step 2: Add new fields to Event struct**
+
+Modify the `Event` struct (around line 8-22) to add new fields:
+
+```go
+type Event struct {
+ Actor *store.UserMessage
+ Type storepb.Activity_Type
+ Comment string
+ // nullable
+ Issue *Issue
+ Project *Project
+ Rollout *Rollout
+
+ // Existing event types
+ IssueUpdate *EventIssueUpdate
+ IssueApprovalCreate *EventIssueApprovalCreate
+ IssueRolloutReady *EventIssueRolloutReady
+ StageStatusUpdate *EventStageStatusUpdate
+ TaskRunStatusUpdate *EventTaskRunStatusUpdate
+
+ // New focused event types
+ IssueCreated *EventIssueCreated
+ ApprovalRequested *EventIssueApprovalRequested
+ SentBack *EventIssueSentBack
+ PipelineFailed *EventPipelineFailed
+ PipelineCompleted *EventPipelineCompleted
+}
+```
+
+**Step 3: Add time import**
+
+Add to imports at top of file:
+
+```go
+import (
+ "time"
+
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ "github.com/bytebase/bytebase/backend/store"
+)
+```
+
+**Step 4: Build to verify**
+
+Run: `go build ./backend/component/webhook/...`
+Expected: Build succeeds with no errors
+
+**Step 5: Commit event struct changes**
+
+```bash
+git add backend/component/webhook/event.go
+git commit -m "feat: add new webhook event data structures
+
+Add event structs for:
+- ISSUE_CREATED
+- ISSUE_APPROVAL_REQUESTED
+- ISSUE_SENT_BACK
+- PIPELINE_FAILED
+- PIPELINE_COMPLETED
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 3: Plugin Layer - Webhook Context Updates
+
+### Task 3: Update Plugin Webhook Context
+
+**Files:**
+- Modify: `backend/plugin/webhook/webhook.go:84-100`
+
+**Step 1: Add new fields to plugin Context struct**
+
+Add after the existing `TaskResult` field (check actual location):
+
+```go
+type Context struct {
+ URL string
+ Level Level
+ EventType string
+ Title string
+ TitleZh string
+ Description string
+ Link string
+ ActorID int
+ ActorName string
+ ActorEmail string
+ CreatedTS int64
+ Issue *Issue
+ Rollout *Rollout
+ Stage *Stage
+ Project *Project
+ TaskResult *TaskResult
+
+ // New event data
+ DirectMessage bool
+ MentionedUsers []*store.UserMessage
+ ApprovalRole string
+ ApprovalRequired int
+ FailedTasks []FailedTaskInfo
+ PipelineMetrics *PipelineMetrics
+}
+
+type FailedTaskInfo struct {
+ Name string
+ Instance string
+ Database string
+ ErrorMessage string
+ FailedAt string
+}
+
+type PipelineMetrics struct {
+ TotalTasks int
+ StartedAt string
+ CompletedAt string
+ DurationSecs int64
+}
+```
+
+**Step 2: Build to verify**
+
+Run: `go build ./backend/plugin/webhook/...`
+Expected: Build succeeds
+
+**Step 3: Commit plugin context changes**
+
+```bash
+git add backend/plugin/webhook/webhook.go
+git commit -m "feat: extend webhook plugin context for new events
+
+Add fields to support:
+- Direct messaging
+- Approval event data
+- Pipeline failure/completion metrics
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 4: Component Layer - Webhook Context Mapping
+
+### Task 4: Update getWebhookContextFromEvent in Manager
+
+**Files:**
+- Modify: `backend/component/webhook/manager.go:72-223`
+
+**Step 1: Add case handlers for new event types**
+
+In the `getWebhookContextFromEvent` method's switch statement, add after the existing cases (around line 94-200):
+
+```go
+ case storepb.Activity_ISSUE_CREATED:
+ title = "Issue created"
+ titleZh = "创建工单"
+ if e.IssueCreated != nil {
+ webhookCtx.Description = fmt.Sprintf("%s created issue %s", e.IssueCreated.CreatorName, e.Issue.Title)
+ }
+
+ case storepb.Activity_ISSUE_APPROVAL_REQUESTED:
+ level = webhook.WebhookWarn
+ title = "Approval required"
+ titleZh = "需要审批"
+ if e.ApprovalRequested != nil {
+ webhookCtx.ApprovalRole = e.ApprovalRequested.ApprovalRole
+ webhookCtx.ApprovalRequired = e.ApprovalRequested.RequiredCount
+ mentionUsers = make([]*store.UserMessage, 0, len(e.ApprovalRequested.Approvers))
+ for _, user := range e.ApprovalRequested.Approvers {
+ mentionUsers = append(mentionUsers, &store.UserMessage{
+ Name: user.Name,
+ Email: user.Email,
+ })
+ }
+ }
+
+ case storepb.Activity_ISSUE_SENT_BACK:
+ level = webhook.WebhookWarn
+ title = "Issue sent back"
+ titleZh = "工单被退回"
+ if e.SentBack != nil {
+ webhookCtx.Description = fmt.Sprintf("%s sent back the issue: %s", e.SentBack.ApproverName, e.SentBack.Reason)
+ mentionUsers = []*store.UserMessage{
+ {
+ Name: e.SentBack.CreatorName,
+ Email: e.SentBack.CreatorEmail,
+ },
+ }
+ }
+
+ case storepb.Activity_PIPELINE_FAILED:
+ level = webhook.WebhookError
+ title = "Pipeline failed"
+ titleZh = "流水线失败"
+ if e.PipelineFailed != nil {
+ failedTasks := make([]webhook.FailedTaskInfo, 0, len(e.PipelineFailed.FailedTasks))
+ for _, task := range e.PipelineFailed.FailedTasks {
+ failedTasks = append(failedTasks, webhook.FailedTaskInfo{
+ Name: task.TaskName,
+ Instance: task.InstanceName,
+ Database: task.DatabaseName,
+ ErrorMessage: task.ErrorMessage,
+ FailedAt: task.FailedAt.Format(time.RFC3339),
+ })
+ }
+ webhookCtx.FailedTasks = failedTasks
+ webhookCtx.Description = fmt.Sprintf("%d task(s) failed", len(failedTasks))
+ }
+
+ case storepb.Activity_PIPELINE_COMPLETED:
+ level = webhook.WebhookSuccess
+ title = "Pipeline completed"
+ titleZh = "流水线完成"
+ if e.PipelineCompleted != nil {
+ duration := e.PipelineCompleted.CompletedAt.Sub(e.PipelineCompleted.StartedAt)
+ webhookCtx.PipelineMetrics = &webhook.PipelineMetrics{
+ TotalTasks: e.PipelineCompleted.TotalTasks,
+ StartedAt: e.PipelineCompleted.StartedAt.Format(time.RFC3339),
+ CompletedAt: e.PipelineCompleted.CompletedAt.Format(time.RFC3339),
+ DurationSecs: int64(duration.Seconds()),
+ }
+ webhookCtx.Description = fmt.Sprintf("Completed %d task(s) in %s", e.PipelineCompleted.TotalTasks, duration.String())
+ }
+```
+
+**Step 2: Build and check for errors**
+
+Run: `go build ./backend/component/webhook/...`
+Expected: Build succeeds
+
+**Step 3: Run golangci-lint**
+
+Run: `golangci-lint run --allow-parallel-runners backend/component/webhook/`
+Expected: No linting errors
+
+**Step 4: Commit webhook context mapping**
+
+```bash
+git add backend/component/webhook/manager.go
+git commit -m "feat: add webhook context mapping for new events
+
+Map new event types to webhook context:
+- ISSUE_CREATED → info message
+- ISSUE_APPROVAL_REQUESTED → warn with approvers
+- ISSUE_SENT_BACK → warn with creator
+- PIPELINE_FAILED → error with failed tasks
+- PIPELINE_COMPLETED → success with metrics
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 5: Event Triggering - Issue Created
+
+### Task 5: Add ISSUE_CREATED Event Trigger
+
+**Files:**
+- Modify: `backend/api/v1/issue_service.go`
+
+**Step 1: Find CreateIssue method**
+
+Run: `grep -n "func.*CreateIssue" backend/api/v1/issue_service.go`
+Note the line number
+
+**Step 2: Add webhook trigger after issue creation**
+
+Find where the issue is successfully created and persisted (look for successful database insert), then add:
+
+```go
+// Trigger ISSUE_CREATED webhook
+s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: user,
+ Type: storepb.Activity_ISSUE_CREATED,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ IssueCreated: &webhook.EventIssueCreated{
+ CreatorName: user.Name,
+ CreatorEmail: user.Email,
+ },
+})
+```
+
+**Step 3: Build to verify**
+
+Run: `go build ./backend/api/v1/...`
+Expected: Build succeeds
+
+**Step 4: Run relevant tests**
+
+Run: `go test -v -count=1 github.com/bytebase/bytebase/backend/api/v1 -run TestIssueService`
+Expected: Tests pass (or identify which tests need updating)
+
+**Step 5: Commit issue created trigger**
+
+```bash
+git add backend/api/v1/issue_service.go
+git commit -m "feat: trigger ISSUE_CREATED webhook event
+
+Send webhook notification when new issue is created.
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 6: Event Triggering - Approval Events
+
+### Task 6: Add ISSUE_APPROVAL_REQUESTED Trigger
+
+**Files:**
+- Modify: `backend/runner/approval/runner.go` or approval handler location
+- Test: Create test to verify approval events
+
+**Step 1: Locate approval flow start point**
+
+Run: `grep -rn "approval.*create\|approval.*start" backend/runner/approval/ backend/api/v1/`
+Identify where approval flow begins
+
+**Step 2: Add helper function to get approvers**
+
+Add to the appropriate file (likely approval runner or issue service):
+
+```go
+func (s *IssueService) getApproversForRole(ctx context.Context, projectID string, role string) ([]webhook.User, error) {
+ // Query IAM policies for users with the approval role
+ policies, err := s.iamManager.GetProjectPolicies(ctx, projectID)
+ if err != nil {
+ return nil, err
+ }
+
+ approvers := []webhook.User{}
+ for _, policy := range policies {
+ if policy.Role == role && policy.PrincipalType == storepb.PrincipalType_END_USER {
+ user, err := s.store.GetUser(ctx, &store.FindUserMessage{
+ Email: &policy.PrincipalEmail,
+ })
+ if err != nil || user == nil || user.Deleted {
+ continue
+ }
+ approvers = append(approvers, webhook.User{
+ Name: user.Name,
+ Email: user.Email,
+ })
+ }
+ }
+ return approvers, nil
+}
+```
+
+**Step 3: Trigger ISSUE_APPROVAL_REQUESTED webhook**
+
+At the approval flow start point, add:
+
+```go
+// Get approvers for this approval step
+approvers, err := s.getApproversForRole(ctx, issue.Project, approvalStep.Role)
+if err != nil {
+ slog.Warn("failed to get approvers", log.BBError(err))
+ approvers = []webhook.User{} // Continue with empty list
+}
+
+// Trigger ISSUE_APPROVAL_REQUESTED webhook
+s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: actor,
+ Type: storepb.Activity_ISSUE_APPROVAL_REQUESTED,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ ApprovalRequested: &webhook.EventIssueApprovalRequested{
+ ApprovalRole: approvalStep.Role,
+ RequiredCount: approvalStep.RequiredApprovals,
+ Approvers: approvers,
+ },
+})
+```
+
+**Step 4: Build and verify**
+
+Run: `go build ./backend/runner/approval/...`
+Expected: Build succeeds
+
+**Step 5: Commit approval requested trigger**
+
+```bash
+git add backend/runner/approval/ backend/api/v1/
+git commit -m "feat: trigger ISSUE_APPROVAL_REQUESTED webhook event
+
+Send notification to approvers when approval is required.
+Includes helper to resolve approvers from IAM policies.
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+### Task 7: Add ISSUE_SENT_BACK Trigger
+
+**Files:**
+- Modify: Approval update handler (likely in `backend/api/v1/` or `backend/runner/approval/`)
+
+**Step 1: Locate approval rejection/send-back handler**
+
+Run: `grep -rn "reject\|send.*back\|approval.*deny" backend/api/v1/ backend/runner/approval/`
+Identify where approver rejects an issue
+
+**Step 2: Add ISSUE_SENT_BACK webhook trigger**
+
+At the rejection point, add:
+
+```go
+// Trigger ISSUE_SENT_BACK webhook
+s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: approver,
+ Type: storepb.Activity_ISSUE_SENT_BACK,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ SentBack: &webhook.EventIssueSentBack{
+ ApproverName: approver.Name,
+ ApproverEmail: approver.Email,
+ Reason: rejectionComment, // Get from approval update payload
+ CreatorName: issue.Creator.Name,
+ CreatorEmail: issue.CreatorEmail,
+ },
+})
+```
+
+**Step 3: Build and verify**
+
+Run: `go build ./backend/api/v1/... ./backend/runner/approval/...`
+Expected: Build succeeds
+
+**Step 4: Commit sent back trigger**
+
+```bash
+git add backend/api/v1/ backend/runner/approval/
+git commit -m "feat: trigger ISSUE_SENT_BACK webhook event
+
+Notify issue creator when approver sends back the issue.
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 7: Pipeline Events - Failure Aggregation
+
+### Task 8: Implement Pipeline Failure Aggregation
+
+**Files:**
+- Modify: `backend/runner/taskrun/scheduler.go`
+- Create: `backend/runner/taskrun/pipeline_events.go`
+
+**Step 1: Create pipeline events tracker**
+
+Create new file `backend/runner/taskrun/pipeline_events.go`:
+
+```go
+package taskrun
+
+import (
+ "sync"
+ "time"
+
+ "github.com/bytebase/bytebase/backend/component/webhook"
+)
+
+// PipelineFailureWindow tracks failed tasks for aggregation
+type PipelineFailureWindow struct {
+ mu sync.Mutex
+ firstFailureTime time.Time
+ failedTasks []webhook.FailedTask
+ notificationSent bool
+ timer *time.Timer
+}
+
+// PipelineEventsTracker manages failure aggregation windows per plan
+type PipelineEventsTracker struct {
+ mu sync.RWMutex
+ windows map[int64]*PipelineFailureWindow // planID -> window
+}
+
+func NewPipelineEventsTracker() *PipelineEventsTracker {
+ return &PipelineEventsTracker{
+ windows: make(map[int64]*PipelineFailureWindow),
+ }
+}
+
+// RecordTaskFailure adds a failed task to the aggregation window
+func (t *PipelineEventsTracker) RecordTaskFailure(planID int64, task webhook.FailedTask, onAggregated func([]webhook.FailedTask)) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ window, exists := t.windows[planID]
+ if !exists || window.notificationSent {
+ // Start new window
+ window = &PipelineFailureWindow{
+ firstFailureTime: time.Now(),
+ failedTasks: []webhook.FailedTask{task},
+ notificationSent: false,
+ }
+ t.windows[planID] = window
+
+ // Set 5-minute timer
+ window.timer = time.AfterFunc(5*time.Minute, func() {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ if w, ok := t.windows[planID]; ok && !w.notificationSent {
+ w.notificationSent = true
+ onAggregated(w.failedTasks)
+ }
+ })
+ } else {
+ // Add to existing window
+ window.mu.Lock()
+ window.failedTasks = append(window.failedTasks, task)
+ window.mu.Unlock()
+ }
+}
+
+// Clear removes the window for a plan (call after pipeline completes)
+func (t *PipelineEventsTracker) Clear(planID int64) {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+
+ if window, exists := t.windows[planID]; exists {
+ if window.timer != nil {
+ window.timer.Stop()
+ }
+ delete(t.windows, planID)
+ }
+}
+```
+
+**Step 2: Add tracker to Scheduler struct**
+
+In `backend/runner/taskrun/scheduler.go`, add field to Scheduler:
+
+```go
+type Scheduler struct {
+ // ... existing fields ...
+ pipelineEvents *PipelineEventsTracker
+}
+```
+
+Initialize in constructor:
+
+```go
+func NewScheduler(...) *Scheduler {
+ return &Scheduler{
+ // ... existing fields ...
+ pipelineEvents: NewPipelineEventsTracker(),
+ }
+}
+```
+
+**Step 3: Hook into task failure detection**
+
+Find where task failures are detected (likely in the task run status update handler), add:
+
+```go
+if taskRun.Status == storepb.TaskRun_FAILED {
+ // Record failure for aggregation
+ s.pipelineEvents.RecordTaskFailure(
+ plan.UID,
+ webhook.FailedTask{
+ TaskID: task.ID,
+ TaskName: task.Name,
+ DatabaseName: database.Name,
+ InstanceName: instance.Name,
+ ErrorMessage: taskRun.Result.GetError(),
+ FailedAt: time.Now(),
+ },
+ func(failedTasks []webhook.FailedTask) {
+ // Send aggregated PIPELINE_FAILED webhook
+ s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: systemUser,
+ Type: storepb.Activity_PIPELINE_FAILED,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ Rollout: webhook.NewRollout(plan),
+ PipelineFailed: &webhook.EventPipelineFailed{
+ FailedTasks: failedTasks,
+ FirstFailureTime: time.Now().Add(-5 * time.Minute),
+ },
+ })
+ },
+ )
+}
+```
+
+**Step 4: Build and verify**
+
+Run: `go build ./backend/runner/taskrun/...`
+Expected: Build succeeds
+
+**Step 5: Commit failure aggregation**
+
+```bash
+git add backend/runner/taskrun/
+git commit -m "feat: implement pipeline failure aggregation
+
+Add 5-minute debouncing window to aggregate failed tasks:
+- Prevents notification spam from cascading failures
+- Sends single PIPELINE_FAILED event with all failures
+- In-memory implementation (non-HA)
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 8: Pipeline Events - Completion Detection
+
+### Task 9: Implement Pipeline Completion Detection
+
+**Files:**
+- Modify: `backend/runner/taskrun/scheduler.go`
+
+**Step 1: Extend ListenTaskSkippedOrDone handler**
+
+Find the `ListenTaskSkippedOrDone` method (around line 79), extend it:
+
+```go
+func (s *Scheduler) ListenTaskSkippedOrDone(ctx context.Context) {
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-s.TaskSkippedOrDoneChan:
+ // ... existing code to check environment completion ...
+
+ // Check if entire plan is complete
+ s.checkPlanCompletion(ctx)
+ }
+ }
+}
+
+func (s *Scheduler) checkPlanCompletion(ctx context.Context) {
+ // Implementation to check if all tasks in plan are done
+ // This needs to query the database for task statuses
+}
+```
+
+**Step 2: Implement plan completion check**
+
+Add helper method:
+
+```go
+func (s *Scheduler) checkPlanCompletion(ctx context.Context) {
+ // Get all running plans
+ plans, err := s.store.ListPlans(ctx, &store.FindPlanMessage{
+ // Query for plans with running tasks
+ })
+ if err != nil {
+ return
+ }
+
+ for _, plan := range plans {
+ allTasks, err := s.store.ListTasks(ctx, &store.FindTaskMessage{
+ PlanID: &plan.UID,
+ })
+ if err != nil {
+ continue
+ }
+
+ allComplete := true
+ hasFailures := false
+ startTime := time.Now()
+ endTime := time.Now()
+
+ for _, task := range allTasks {
+ taskRuns, err := s.store.ListTaskRuns(ctx, &store.FindTaskRunMessage{
+ TaskID: &task.ID,
+ })
+ if err != nil || len(taskRuns) == 0 {
+ continue
+ }
+
+ latestRun := taskRuns[0] // Assuming sorted by creation time desc
+
+ if latestRun.Status != storepb.TaskRun_DONE &&
+ latestRun.Status != storepb.TaskRun_FAILED &&
+ latestRun.Status != storepb.TaskRun_CANCELED &&
+ latestRun.Status != storepb.TaskRun_SKIPPED {
+ allComplete = false
+ break
+ }
+
+ if latestRun.Status == storepb.TaskRun_FAILED {
+ hasFailures = true
+ }
+
+ // Track start/end times
+ if latestRun.CreatedTime.Before(startTime) {
+ startTime = latestRun.CreatedTime
+ }
+ if latestRun.UpdatedTime.After(endTime) {
+ endTime = latestRun.UpdatedTime
+ }
+ }
+
+ if allComplete && !hasFailures {
+ // Clear any pending failure windows
+ s.pipelineEvents.Clear(plan.UID)
+
+ // Send PIPELINE_COMPLETED webhook
+ issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
+ PlanUID: &plan.UID,
+ })
+ if err != nil {
+ continue
+ }
+
+ project, err := s.store.GetProject(ctx, &store.FindProjectMessage{
+ ResourceID: &issue.Project,
+ })
+ if err != nil {
+ continue
+ }
+
+ s.webhookManager.CreateEvent(ctx, &webhook.Event{
+ Actor: &store.UserMessage{Name: "System", Email: "[email protected]"},
+ Type: storepb.Activity_PIPELINE_COMPLETED,
+ Project: webhook.NewProject(project),
+ Issue: webhook.NewIssue(issue),
+ Rollout: webhook.NewRollout(plan),
+ PipelineCompleted: &webhook.EventPipelineCompleted{
+ TotalTasks: len(allTasks),
+ StartedAt: startTime,
+ CompletedAt: endTime,
+ },
+ })
+ }
+ }
+}
+```
+
+**Step 3: Build and verify**
+
+Run: `go build ./backend/runner/taskrun/...`
+Expected: Build succeeds
+
+**Step 4: Commit pipeline completion**
+
+```bash
+git add backend/runner/taskrun/scheduler.go
+git commit -m "feat: implement pipeline completion detection
+
+Detect when all tasks in pipeline complete successfully:
+- Extends ListenTaskSkippedOrDone handler
+- Checks all task run statuses
+- Sends PIPELINE_COMPLETED webhook
+- Clears failure aggregation windows
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 9: Plugin Updates - Slack
+
+### Task 10: Update Slack Plugin for New Events
+
+**Files:**
+- Modify: `backend/plugin/webhook/slack/slack.go`
+
+**Step 1: Locate message formatting function**
+
+Run: `grep -n "func.*Post" backend/plugin/webhook/slack/slack.go`
+Find the main message formatting function
+
+**Step 2: Add cases for new event types**
+
+In the event type switch/if-else chain, add:
+
+```go
+case "ISSUE_CREATED":
+ text = fmt.Sprintf("🆕 *%s*\n%s", context.Title, context.Description)
+ color = "#36A64F" // Green
+
+case "ISSUE_APPROVAL_REQUESTED":
+ text = fmt.Sprintf("⚠️ *%s*\nRole: %s\nRequired: %d approval(s)",
+ context.Title, context.ApprovalRole, context.ApprovalRequired)
+ color = "#FF9900" // Orange
+
+ if context.DirectMessage && len(context.MentionedUsers) > 0 {
+ // Send DM to each approver
+ // Implementation depends on Slack IM integration
+ }
+
+case "ISSUE_SENT_BACK":
+ text = fmt.Sprintf("↩️ *%s*\n%s", context.Title, context.Description)
+ color = "#FF9900" // Orange
+
+case "PIPELINE_FAILED":
+ failedTasksText := ""
+ for _, task := range context.FailedTasks {
+ failedTasksText += fmt.Sprintf("\n• %s (%s.%s): %s",
+ task.Name, task.Instance, task.Database, task.ErrorMessage)
+ }
+ text = fmt.Sprintf("❌ *%s*\n%d task(s) failed:%s",
+ context.Title, len(context.FailedTasks), failedTasksText)
+ color = "#FF0000" // Red
+
+case "PIPELINE_COMPLETED":
+ if context.PipelineMetrics != nil {
+ duration := time.Duration(context.PipelineMetrics.DurationSecs) * time.Second
+ text = fmt.Sprintf("✅ *%s*\nCompleted %d task(s) in %s",
+ context.Title, context.PipelineMetrics.TotalTasks, duration.String())
+ }
+ color = "#36A64F" // Green
+```
+
+**Step 3: Build and verify**
+
+Run: `go build ./backend/plugin/webhook/...`
+Expected: Build succeeds
+
+**Step 4: Commit Slack plugin updates**
+
+```bash
+git add backend/plugin/webhook/slack/
+git commit -m "feat: add Slack formatting for new webhook events
+
+Support new event types:
+- ISSUE_CREATED
+- ISSUE_APPROVAL_REQUESTED (with DM support)
+- ISSUE_SENT_BACK
+- PIPELINE_FAILED (with task details)
+- PIPELINE_COMPLETED (with metrics)
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 10: Plugin Updates - Other Platforms
+
+### Task 11: Update Discord Plugin
+
+**Files:**
+- Modify: `backend/plugin/webhook/discord.go`
+
+**Step 1: Add formatting for new events**
+
+Similar to Slack, add cases for new event types with Discord-specific formatting (embeds).
+
+**Step 2: Build and commit**
+
+```bash
+git add backend/plugin/webhook/discord.go
+git commit -m "feat: add Discord formatting for new webhook events
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+### Task 12: Update Teams Plugin
+
+**Files:**
+- Modify: `backend/plugin/webhook/teams.go` (if exists) or relevant Teams file
+
+**Step 1: Add formatting for new events**
+
+Add Teams-specific message card formatting.
+
+**Step 2: Build and commit**
+
+```bash
+git add backend/plugin/webhook/teams.go
+git commit -m "feat: add Teams formatting for new webhook events
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+### Task 13: Update Feishu Plugin
+
+**Files:**
+- Modify: `backend/plugin/webhook/feishu.go` (if exists)
+
+**Step 1: Add formatting for new events**
+
+Add Feishu/Lark message formatting with Chinese translations.
+
+**Step 2: Build and commit**
+
+```bash
+git add backend/plugin/webhook/feishu.go
+git commit -m "feat: add Feishu formatting for new webhook events
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 11: Testing
+
+### Task 14: Add Component Layer Tests
+
+**Files:**
+- Create: `backend/component/webhook/event_test.go`
+
+**Step 1: Write test for event struct creation**
+
+```go
+package webhook
+
+import (
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestEventIssueCreated(t *testing.T) {
+ event := &Event{
+ Type: storepb.Activity_ISSUE_CREATED,
+ IssueCreated: &EventIssueCreated{
+ CreatorName: "Alice",
+ CreatorEmail: "[email protected]",
+ },
+ }
+
+ assert.NotNil(t, event.IssueCreated)
+ assert.Equal(t, "Alice", event.IssueCreated.CreatorName)
+}
+
+func TestEventApprovalRequested(t *testing.T) {
+ approvers := []User{
+ {Name: "Bob", Email: "[email protected]"},
+ {Name: "Carol", Email: "[email protected]"},
+ }
+
+ event := &Event{
+ Type: storepb.Activity_ISSUE_APPROVAL_REQUESTED,
+ ApprovalRequested: &EventIssueApprovalRequested{
+ ApprovalRole: "Project Owner",
+ RequiredCount: 2,
+ Approvers: approvers,
+ },
+ }
+
+ assert.Equal(t, 2, len(event.ApprovalRequested.Approvers))
+ assert.Equal(t, "Project Owner", event.ApprovalRequested.ApprovalRole)
+}
+
+func TestFailedTaskTracking(t *testing.T) {
+ failedTask := FailedTask{
+ TaskID: 1,
+ TaskName: "Migration",
+ DatabaseName: "prod",
+ InstanceName: "prod-1",
+ ErrorMessage: "syntax error",
+ FailedAt: time.Now(),
+ }
+
+ event := &Event{
+ Type: storepb.Activity_PIPELINE_FAILED,
+ PipelineFailed: &EventPipelineFailed{
+ FailedTasks: []FailedTask{failedTask},
+ },
+ }
+
+ assert.Equal(t, 1, len(event.PipelineFailed.FailedTasks))
+ assert.Equal(t, "syntax error", event.PipelineFailed.FailedTasks[0].ErrorMessage)
+}
+```
+
+**Step 2: Run tests**
+
+Run: `go test -v ./backend/component/webhook/`
+Expected: All tests pass
+
+**Step 3: Commit tests**
+
+```bash
+git add backend/component/webhook/event_test.go
+git commit -m "test: add unit tests for new webhook event structs
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+### Task 15: Add Pipeline Events Tracker Tests
+
+**Files:**
+- Create: `backend/runner/taskrun/pipeline_events_test.go`
+
+**Step 1: Write aggregation tests**
+
+```go
+package taskrun
+
+import (
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/bytebase/bytebase/backend/component/webhook"
+)
+
+func TestPipelineFailureAggregation(t *testing.T) {
+ tracker := NewPipelineEventsTracker()
+
+ var aggregatedTasks []webhook.FailedTask
+ var mu sync.Mutex
+
+ onAggregated := func(tasks []webhook.FailedTask) {
+ mu.Lock()
+ defer mu.Unlock()
+ aggregatedTasks = tasks
+ }
+
+ // Record first failure
+ task1 := webhook.FailedTask{
+ TaskID: 1,
+ TaskName: "Migration 1",
+ FailedAt: time.Now(),
+ }
+ tracker.RecordTaskFailure(100, task1, onAggregated)
+
+ // Record second failure within window
+ task2 := webhook.FailedTask{
+ TaskID: 2,
+ TaskName: "Migration 2",
+ FailedAt: time.Now(),
+ }
+ tracker.RecordTaskFailure(100, task2, onAggregated)
+
+ // Wait for aggregation (with timeout for testing)
+ time.Sleep(5*time.Minute + 100*time.Millisecond)
+
+ mu.Lock()
+ defer mu.Unlock()
+ assert.Equal(t, 2, len(aggregatedTasks))
+}
+
+func TestPipelineFailureNewWindowAfterNotification(t *testing.T) {
+ // Test that new failures after notification start a new window
+ tracker := NewPipelineEventsTracker()
+
+ // ... test implementation
+}
+
+func TestClearPipelineWindow(t *testing.T) {
+ tracker := NewPipelineEventsTracker()
+
+ task := webhook.FailedTask{TaskID: 1}
+ tracker.RecordTaskFailure(100, task, func([]webhook.FailedTask) {})
+
+ tracker.Clear(100)
+
+ // Verify window is cleared
+ tracker.mu.RLock()
+ defer tracker.mu.RUnlock()
+ assert.NotContains(t, tracker.windows, int64(100))
+}
+```
+
+**Step 2: Run tests**
+
+Run: `go test -v ./backend/runner/taskrun/ -run TestPipeline`
+Expected: Tests pass
+
+**Step 3: Commit tests**
+
+```bash
+git add backend/runner/taskrun/pipeline_events_test.go
+git commit -m "test: add tests for pipeline failure aggregation
+
+Test 5-minute debouncing window and aggregation logic.
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 12: Integration & Documentation
+
+### Task 16: Run Full Test Suite
+
+**Step 1: Run all tests**
+
+Run: `go test -v -count=1 ./backend/...`
+Expected: All tests pass
+
+**Step 2: Fix any failing tests**
+
+If tests fail, identify and fix issues related to the new event types.
+
+**Step 3: Run linter**
+
+Run: `golangci-lint run --allow-parallel-runners`
+Expected: No linting errors (run multiple times until clean)
+
+**Step 4: Format code**
+
+Run: `gofmt -w backend/`
+Expected: All files formatted
+
+**Step 5: Build backend**
+
+Run: `go build -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go`
+Expected: Build succeeds
+
+---
+
+### Task 17: Update Design Document Status
+
+**Files:**
+- Modify: `docs/plans/2025-12-30-webhook-events-redesign.md:4`
+
+**Step 1: Update status to Implemented**
+
+Change line 4:
+```markdown
+**Status:** Implemented
+```
+
+**Step 2: Commit documentation**
+
+```bash
+git add docs/plans/2025-12-30-webhook-events-redesign.md
+git commit -m "docs: mark webhook redesign as implemented
+
+🤖 Generated with Claude Code
+Co-Authored-By: Claude Sonnet 4.5 <[email protected]>"
+```
+
+---
+
+## Phase 13: Final Review & Merge Preparation
+
+### Task 18: Final Code Review
+
+**Step 1: Review all changes**
+
+Run: `git diff main...feature/webhook-events-redesign --stat`
+Review files changed
+
+**Step 2: Create PR checklist**
+
+Verify:
+- [ ] All 5 new Activity.Type enums added
+- [ ] Component layer event structs created
+- [ ] Plugin context extended
+- [ ] All 5 event triggers implemented
+- [ ] Pipeline failure aggregation works
+- [ ] Pipeline completion detection works
+- [ ] All plugins updated (Slack, Discord, Teams, Feishu)
+- [ ] Tests added and passing
+- [ ] Linter passes
+- [ ] Backend builds successfully
+- [ ] Documentation updated
+
+**Step 3: Run verification build and tests**
+
+```bash
+# Full backend build
+go build -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go
+
+# All tests
+go test -v -count=1 ./backend/component/webhook/... ./backend/runner/taskrun/...
+
+# Lint
+golangci-lint run --allow-parallel-runners
+```
+
+Expected: All succeed
+
+---
+
+## Summary
+
+This implementation adds 5 focused webhook event types to replace the existing 9 noisy events:
+
+**New Events:**
+1. ISSUE_CREATED - Simple notification when issues are created
+2. ISSUE_APPROVAL_REQUESTED - Direct message to approvers
+3. ISSUE_SENT_BACK - Direct message to issue creator
+4. PIPELINE_FAILED - Aggregated failures with 5-minute debouncing
+5. PIPELINE_COMPLETED - Success notification
+
+**Key Features:**
+- Proto-based type safety with storepb.Activity_Type enums
+- Clean component/plugin separation
+- 5-minute failure aggregation prevents notification spam
+- Direct messaging support for approval events
+- Backward compatible (old events still in proto)
+
+**Testing:**
+- Unit tests for event structs
+- Unit tests for failure aggregation
+- Integration tests for triggers
+- Full backend build verification
diff --git a/docs/plans/2025-12-30-webhook-events-redesign.md b/docs/plans/2025-12-30-webhook-events-redesign.md
new file mode 100644
index 0000000000..5e8dd0f10e
--- /dev/null
+++ b/docs/plans/2025-12-30-webhook-events-redesign.md
@@ -0,0 +1,389 @@
+# Webhook Events Redesign
+
+**Date:** 2025-12-30
+**Status:** Design
+**Author:** Danny
+
+## Overview
+
+This document outlines a redesign of the webhook notification system to reduce noise, improve signal quality, and provide better targeting for notifications. The current system sends too many notifications for granular events (field updates, task status changes) while sometimes missing important outcomes (pipeline failures, completions).
+
+## Goals
+
+1. **Reduce noise** - From 9 event types to 5 focused events
+2. **Better signal** - Notify on outcomes (failed/completed) not intermediate steps
+3. **Smart routing** - Direct messages for action-required events, channels for awareness
+4. **Failure aggregation** - 5-minute window prevents notification spam from cascading failures
+
+## Event Model
+
+### New Event Types (5 total)
+
+**Approval Events (Direct Message capable):**
+- `ISSUE_APPROVAL_REQUESTED` - Replaces `ISSUE_APPROVAL_NOTIFY`
+ - Triggered: When issue approval flow starts OR user re-requests approval
+ - Audience: Users with required approval role (from IAM policies)
+
+- `ISSUE_SENT_BACK` - New event type
+ - Triggered: When approver rejects/sends back the issue
+ - Audience: Issue creator
+
+**Issue Lifecycle Events (Channel only):**
+- `ISSUE_CREATED` - Replaces `ISSUE_CREATE`
+ - Triggered: New issue created via API
+ - Audience: All subscribed webhooks
+
+**Pipeline Events (Channel only):**
+- `PIPELINE_FAILED` - New event type with aggregation
+ - Triggered: 5 minutes after first task failure (debounced aggregation)
+ - Audience: All subscribed webhooks
+ - Note: Non-HA implementation initially (in-memory state)
+
+- `PIPELINE_COMPLETED` - New event type
+ - Triggered: All tasks in plan reach terminal state (DONE/SKIPPED) with no failures
+ - Audience: All subscribed webhooks
+ - Note: Non-HA implementation initially
+
+### Removed Events
+
+These existing events will be deprecated:
+
+- ~~`ISSUE_COMMENT_CREATE`~~ - Too noisy
+- ~~`ISSUE_FIELD_UPDATE`~~ - Too noisy
+- ~~`ISSUE_STATUS_UPDATE`~~ - Redundant with lifecycle events
+- ~~`NOTIFY_ISSUE_APPROVED`~~ - Implicit in issue completion
+- ~~`NOTIFY_PIPELINE_ROLLOUT`~~ - Redundant with pipeline events
+- ~~`ISSUE_PIPELINE_STAGE_STATUS_UPDATE`~~ - Too granular, replaced by `PIPELINE_COMPLETED`
+- ~~`ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE`~~ - Too granular, replaced by `PIPELINE_FAILED`
+
+### Event Type Mapping
+
+| Old Event Type | New Event Type | Notes |
+|----------------|----------------|-------|
+| `ISSUE_CREATE` (1) | `ISSUE_CREATED` (10) | Renamed for consistency |
+| `ISSUE_APPROVAL_NOTIFY` (6) | `ISSUE_APPROVAL_REQUESTED` (11) | Covers initial + re-request |
+| `ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE` (7) | `PIPELINE_FAILED` (13) | Aggregated failures |
+| `ISSUE_PIPELINE_STAGE_STATUS_UPDATE` (5) | `PIPELINE_COMPLETED` (14) | Success only |
+
+## Data Architecture
+
+### Component Layer (backend/component/webhook)
+
+The component layer provides raw event data using proto-generated enums:
+
+```go
+type WebhookContext struct {
+ EventType storepb.Activity_Type // Proto enum: ISSUE_CREATED, etc.
+
+ // Direct messaging configuration
+ DirectMessage bool
+
+ // Event-specific data (only one populated per event)
+ IssueCreated *IssueCreatedEvent
+ ApprovalRequested *IssueApprovalRequestedEvent
+ SentBack *IssueSentBackEvent
+ PipelineFailed *PipelineFailedEvent
+ PipelineCompleted *PipelineCompletedEvent
+}
+
+type IssueCreatedEvent struct {
+ IssueID int64
+ IssueTitle string
+ IssueType string // "DATABASE_CHANGE", "GRANT_REQUEST", etc.
+ ProjectID string
+ CreatorName string
+ CreatorEmail string
+}
+
+type IssueApprovalRequestedEvent struct {
+ IssueID int64
+ IssueTitle string
+ ProjectID string
+ ApprovalRole string // "Project Owner"
+ RequiredCount int // How many approvals needed
+ Approvers []User // List of people to notify
+}
+
+type IssueSentBackEvent struct {
+ IssueID int64
+ IssueTitle string
+ ProjectID string
+ ApproverName string
+ ApproverEmail string
+ Reason string // Rejection comment
+ CreatorName string
+ CreatorEmail string // Person to notify
+}
+
+type PipelineFailedEvent struct {
+ IssueID int64
+ IssueTitle string
+ PlanID int64
+ FailedTasks []FailedTask
+}
+
+type FailedTask struct {
+ TaskID int64
+ TaskName string
+ DatabaseName string
+ InstanceName string
+ ErrorMessage string
+ FailedAt time.Time
+}
+
+type PipelineCompletedEvent struct {
+ IssueID int64
+ IssueTitle string
+ PlanID int64
+ TotalTasks int
+ StartedAt time.Time
+ CompletedAt time.Time
+}
+
+type User struct {
+ Name string
+ Email string
+}
+```
+
+### Plugin Layer (backend/plugin/webhook)
+
+Each plugin (Slack, Discord, Teams, Feishu, etc.) receives the `WebhookContext` and handles:
+- Title/description rendering (in their preferred language)
+- URL construction from IssueID to Bytebase UI
+- Message formatting according to platform
+- Direct message delivery (if DirectMessage = true)
+
+Plugins decide all presentation details. The component layer only provides raw data.
+
+## Configuration & Storage
+
+### Database Schema
+
+Uses existing `project_webhook` table - **no schema changes needed**:
+
+```sql
+CREATE TABLE project_webhook (
+ id serial PRIMARY KEY,
+ project text NOT NULL REFERENCES project(resource_id),
+ -- Stored as ProjectWebhook proto
+ payload jsonb NOT NULL DEFAULT '{}'
+);
+```
+
+### Proto Changes
+
+Update `proto/store/store/project_webhook.proto` - modify Activity.Type enum:
+
+**Add new activity types:**
+```proto
+enum Activity {
+ enum Type {
+ // ... existing types ...
+
+ // New focused event types
+ ISSUE_CREATED = 10;
+ ISSUE_APPROVAL_REQUESTED = 11;
+ ISSUE_SENT_BACK = 12;
+ PIPELINE_FAILED = 13;
+ PIPELINE_COMPLETED = 14;
+ }
+}
+```
+
+**Existing ProjectWebhook proto (no changes):**
+```proto
+message ProjectWebhook {
+ WebhookType type = 1; // SLACK, DISCORD, TEAMS, etc.
+ string title = 2;
+ string url = 3;
+ repeated Activity.Type activities = 4; // Event subscriptions
+ bool direct_message = 5; // Enable IM direct messaging
+}
+```
+
+### Direct Message Behavior
+
+The `direct_message` field in ProjectWebhook controls delivery:
+
+**When `direct_message = true`:**
+- `ISSUE_APPROVAL_REQUESTED` → sends individual DMs to each user in `Approvers[]`
+- `ISSUE_SENT_BACK` → sends DM to `CreatorEmail`
+- Other events (ISSUE_CREATED, PIPELINE_*) → POST to webhook `url` (channel events ignore DM flag)
+
+**When `direct_message = false`:**
+- All subscribed events POST to webhook `url`
+
+**IM Integration:**
+Direct messaging requires IM integration settings in the webhook payload JSONB:
+```json
+{
+ "im_type": "feishu",
+ "app_id": "cli_xxx",
+ "app_secret": "xxx"
+}
+```
+
+## Pipeline Failure Aggregation
+
+### Problem
+
+Multiple tasks failing in quick succession creates notification spam. For example, a migration failing across 10 databases could trigger 10 separate notifications.
+
+### Solution
+
+5-minute debounced aggregation window:
+
+1. **First task fails** → Start 5-minute timer, collect failed task info
+2. **More tasks fail within 5 minutes** → Add to collection, don't notify yet
+3. **After 5 minutes** → Send single `PIPELINE_FAILED` event with all failed tasks
+4. **Subsequent failures after notification** → Start new 5-minute window
+
+### Implementation
+
+**Approach:** In-memory state tracking (non-HA)
+
+Pipeline events will use in-memory aggregation similar to the existing `RunningTaskRuns` pattern:
+
+```go
+type PipelineFailureWindow struct {
+ FirstFailureTime time.Time
+ FailedTasks []*FailedTaskInfo
+ NotificationSent bool
+ Timer *time.Timer
+}
+```
+
+**Location:** Extend existing `ListenTaskSkippedOrDone` in `backend/runner/taskrun/scheduler.go`
+
+**Future Migration:**
+- Can migrate to DB-based `webhook_pending_event` table for HA when needed
+- Would use `FOR UPDATE SKIP LOCKED` pattern for distributed coordination
+- Won't require payload changes, only implementation changes
+
+## Event Triggering & Delivery
+
+### Trigger Points
+
+| Event | Trigger Location | Condition |
+|-------|-----------------|-----------|
+| `ISSUE_CREATED` | `backend/api/v1/issue_service.go` - `CreateIssue()` | After issue persisted to DB |
+| `ISSUE_APPROVAL_REQUESTED` | Approval runner or issue update handler | Approval flow starts or re-requested |
+| `ISSUE_SENT_BACK` | Approval update handler | Approver rejects/sends back |
+| `PIPELINE_FAILED` | `backend/runner/taskrun/scheduler.go` | 5-min after first failure |
+| `PIPELINE_COMPLETED` | Extend `ListenTaskSkippedOrDone` in scheduler.go | All tasks terminal, no failures |
+
+### Delivery Flow
+
+1. Event occurs → Component layer creates `WebhookContext` with appropriate event data
+2. Query `project_webhook` table for webhooks subscribed to this event type
+3. For each matching webhook:
+ - If `direct_message = true` AND event is approval-related → send individual DMs
+ - Otherwise → POST to webhook URL
+4. Delivery happens asynchronously (background goroutine to avoid blocking)
+5. 3-second timeout per webhook, with retry on transient errors
+
+### Audience Resolution
+
+**ISSUE_APPROVAL_REQUESTED:**
+- Query IAM policies (project + workspace level)
+- Find users with the required approval role
+- Filter: `END_USER` principal type only (no service accounts)
+- Exclude deleted members
+
+**ISSUE_SENT_BACK:**
+- Issue creator (stored in issue record)
+
+**Other events:**
+- No user-specific targeting, all go to configured webhook URLs
+
+## Implementation Checklist
+
+### Proto Changes
+- [ ] Update `proto/store/store/project_webhook.proto` - add new Activity.Type values (10-14)
+- [ ] Run `cd proto && buf format -w` and `buf generate`
+
+### Component Layer
+- [ ] Create new event structs in `backend/component/webhook/`
+- [ ] Update `WebhookContext` struct to use proto enums
+- [ ] Implement audience resolution for approval events
+
+### Event Triggers
+- [ ] Add `ISSUE_CREATED` trigger in `backend/api/v1/issue_service.go`
+- [ ] Add `ISSUE_APPROVAL_REQUESTED` trigger in approval handlers
+- [ ] Add `ISSUE_SENT_BACK` trigger in approval update handler
+- [ ] Implement pipeline failure aggregation in `backend/runner/taskrun/scheduler.go`
+- [ ] Implement pipeline completion detection in scheduler
+
+### Plugin Layer
+- [ ] Update plugins to handle new event types:
+ - `backend/plugin/webhook/slack/`
+ - `backend/plugin/webhook/discord.go`
+ - `backend/plugin/webhook/teams.go`
+ - `backend/plugin/webhook/feishu.go`
+ - Other webhook plugins
+
+### Testing
+- [ ] Unit tests for event creation
+- [ ] Unit tests for failure aggregation logic
+- [ ] Integration tests for direct messaging
+- [ ] Integration tests for channel webhooks
+
+## Migration Strategy
+
+### Backward Compatibility
+
+Old Activity.Type values (1-9) will remain in the proto but marked as deprecated. Existing webhooks subscribed to old events will continue working until users update their subscriptions.
+
+**Migration path:**
+1. Deploy new code with both old and new event types supported
+2. UI can show "deprecated" tags on old event types
+3. Provide migration tool or guide for users to update webhook subscriptions
+4. Eventually remove old event handling code in future major version
+
+### Rollout Plan
+
+1. **Phase 1:** Deploy proto changes and new event structs (no functional change yet)
+2. **Phase 2:** Deploy new event triggers alongside old ones (both systems running)
+3. **Phase 3:** Update plugins to handle new event types
+4. **Phase 4:** UI updates to show new event types in webhook configuration
+5. **Phase 5:** Deprecation notices for old event types
+6. **Future:** Remove old event handling code
+
+## Future Enhancements
+
+### HA Support for Pipeline Events
+
+Current implementation uses in-memory state for failure aggregation. For multi-replica HA deployments:
+
+**Proposed approach:**
+- Add `webhook_pending_event` table
+- Use `FOR UPDATE SKIP LOCKED` for distributed coordination
+- Background job aggregates and sends notifications
+- Details TBD when HA requirement becomes active
+
+### Additional Event Types
+
+Potential future additions based on user feedback:
+- `ISSUE_CANCELED` - When issue is explicitly canceled
+- `ISSUE_COMPLETED` - When issue reaches done state
+- `PIPELINE_CANCELED` - When pipeline is stopped by user
+
+These are intentionally excluded from initial design to keep it focused.
+
+## Summary
+
+This redesign reduces webhook noise while improving signal quality:
+
+| Metric | Before | After |
+|--------|--------|-------|
+| Event types | 9 | 5 |
+| Noisy events | Yes (comments, field updates) | No |
+| Pipeline spam | Yes (per-task notifications) | No (5-min aggregation) |
+| Action targeting | Partial (DM for approvals) | Better (DM for all approval events) |
+
+**Key benefits:**
+- Teams receive fewer, more meaningful notifications
+- Approval events properly target specific users via DM
+- Pipeline failures aggregate to prevent notification storms
+- Clean data architecture with proto enums throughout
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index a281814a41..2359d0d4e5 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1862,37 +1862,21 @@
"title": "Issue creation",
"label": "When new issue has been created"
},
- "issue-status-change": {
- "title": "Issue status change",
- "label": "When issue status has changed"
- },
- "issue-stage-status-change": {
- "title": "Issue stage status change",
- "label": "When issue's enclosing stage status has changed"
- },
- "issue-task-status-change": {
- "title": "Issue task status change",
- "label": "When issue's enclosing task status has changed"
- },
- "issue-info-change": {
- "title": "Issue info change",
- "label": "When issue info (e.g. title, description) has changed"
- },
- "issue-comment-creation": {
- "title": "Issue comment creation",
- "label": "When new issue comment has been created"
- },
"issue-approval-notify": {
"title": "Issue approval needed",
"label": "When issue is pending approval"
},
- "notify-issue-approved": {
- "title": "Issue approved",
- "label": "When issue is approved"
+ "issue-sent-back": {
+ "title": "Issue sent back",
+ "label": "When issue is sent back by an approver"
+ },
+ "pipeline-failed": {
+ "title": "Pipeline failed",
+ "label": "When pipeline tasks fail"
},
- "notify-pipeline-rollout": {
- "title": "Issue rollout needed",
- "label": "When the issue is waiting for rollout"
+ "pipeline-completed": {
+ "title": "Pipeline completed",
+ "label": "When pipeline completes successfully"
}
}
},
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index d68e5183b7..bdf41662f0 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1862,37 +1862,21 @@
"title": "Creación de incidencia",
"label": "Cuando se crea una nueva incidencia"
},
- "issue-status-change": {
- "title": "Cambio de estado de incidencia",
- "label": "Cuando se cambia el estado de la incidencia"
- },
- "issue-stage-status-change": {
- "title": "Cambio de estado de etapa de incidencia",
- "label": "Cuando cambia el estado de la etapa que encierra la incidencia"
- },
- "issue-task-status-change": {
- "title": "Cambio de estado de tarea de incidencia",
- "label": "Cuando cambia el estado de la tarea que encierra la incidencia"
- },
- "issue-info-change": {
- "title": "Cambio de información de incidencia",
- "label": "Cuando cambia la información de la incidencia (por ejemplo, título, descripción)"
- },
- "issue-comment-creation": {
- "title": "Creación de comentario de incidencia",
- "label": "Cuando se crea un nuevo comentario en la incidencia"
- },
"issue-approval-notify": {
"title": "Notificación de aprobación de incidencia",
- "label": "Cuando se aprueba o rechaza una incidencia"
+ "label": "Cuando se requiere aprobación de incidencia"
+ },
+ "issue-sent-back": {
+ "title": "Incidencia devuelta",
+ "label": "Cuando un aprobador devuelve la incidencia"
},
- "notify-issue-approved": {
- "title": "Asunto aprobado",
- "label": "Cuando se aprueba la emisión"
+ "pipeline-failed": {
+ "title": "Pipeline fallido",
+ "label": "Cuando las tareas del pipeline fallan"
},
- "notify-pipeline-rollout": {
- "title": "Se necesita implementar el problema",
- "label": "Cuando el problema está esperando la implementación"
+ "pipeline-completed": {
+ "title": "Pipeline completado",
+ "label": "Cuando el pipeline se completa con éxito"
}
}
},
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 740a5e7fda..aa5bc5a284 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1862,37 +1862,21 @@
"title": "@:common.issue を作成する",
"label": "新しいイシューが作成されたとき"
},
- "issue-status-change": {
- "title": "イシューのステータスの変更",
- "label": "イシューのステータスが変更されたとき"
- },
- "issue-stage-status-change": {
- "title": "イシューのステージのステータスの変更",
- "label": "イシューに含まれるステージステータスが変更されたとき"
- },
- "issue-task-status-change": {
- "title": "イシューのタスクのステータスの変更",
- "label": "イシューに含まれるタスクのステータスが変更されたとき"
- },
- "issue-info-change": {
- "title": "イシューの情報の変更",
- "label": "イシューの情報 (例: タイトル、説明) が変更されたとき"
- },
- "issue-comment-creation": {
- "title": "イシューへのコメント",
- "label": "新しいイシューコメントが作成されたとき"
- },
"issue-approval-notify": {
"title": "イシューは承認待ちです",
"label": "イシューに承認が必要な場合"
},
- "notify-issue-approved": {
- "title": "イシューが承認されました",
- "label": "イシューが承認されたとき"
+ "issue-sent-back": {
+ "title": "イシューが差し戻されました",
+ "label": "承認者がイシューを差し戻したとき"
+ },
+ "pipeline-failed": {
+ "title": "パイプラインが失敗しました",
+ "label": "パイプラインタスクが失敗したとき"
},
- "notify-pipeline-rollout": {
- "title": "リリースされる作業命令",
- "label": "イシューがリリース保留中の場合"
+ "pipeline-completed": {
+ "title": "パイプラインが完了しました",
+ "label": "パイプラインが正常に完了したとき"
}
}
},
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 7dcd57c757..9464b25ba4 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1862,37 +1862,21 @@
"title": "Tạo vấn đề",
"label": "Khi vấn đề mới được tạo"
},
- "issue-status-change": {
- "title": "Thay đổi trạng thái vấn đề",
- "label": "Khi trạng thái vấn đề đã thay đổi"
- },
- "issue-stage-status-change": {
- "title": "Thay đổi trạng thái giai đoạn vấn đề",
- "label": "Khi trạng thái giai đoạn kèm theo của vấn đề đã thay đổi"
- },
- "issue-task-status-change": {
- "title": "Thay đổi trạng thái tác vụ vấn đề",
- "label": "Khi trạng thái tác vụ kèm theo của vấn đề đã thay đổi"
- },
- "issue-info-change": {
- "title": "Thay đổi thông tin vấn đề",
- "label": "Khi thông tin vấn đề (ví dụ: tiêu đề, mô tả) đã thay đổi"
- },
- "issue-comment-creation": {
- "title": "Tạo bình luận vấn đề",
- "label": "Khi bình luận vấn đề mới được tạo"
- },
"issue-approval-notify": {
"title": "Cần phê duyệt vấn đề",
"label": "Khi vấn đề đang chờ phê duyệt"
},
- "notify-issue-approved": {
- "title": "Vấn đề được chấp thuận",
- "label": "Khi vấn đề được chấp thuận"
+ "issue-sent-back": {
+ "title": "Vấn đề bị trả lại",
+ "label": "Khi người phê duyệt trả lại vấn đề"
+ },
+ "pipeline-failed": {
+ "title": "Pipeline thất bại",
+ "label": "Khi các tác vụ pipeline thất bại"
},
- "notify-pipeline-rollout": {
- "title": "Cần triển khai vấn đề",
- "label": "Khi vấn đề đang chờ triển khai"
+ "pipeline-completed": {
+ "title": "Pipeline hoàn thành",
+ "label": "Khi pipeline hoàn thành thành công"
}
}
},
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index ab0c6de9bb..1ebd542ca3 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1862,37 +1862,21 @@
"title": "创建@:common.issue",
"label": "当一个新的工单被创建"
},
- "issue-status-change": {
- "title": "工单状态变更",
- "label": "当一个工单的状态发生变更"
- },
- "issue-stage-status-change": {
- "title": "工单阶段状态变更",
- "label": "当一个工单包含的阶段状态发生了变更"
- },
- "issue-task-status-change": {
- "title": "工单任务状态变更",
- "label": "当一个工单包含的任务状态发生了变更"
- },
- "issue-info-change": {
- "title": "工单信息变更",
- "label": "当一个工单的信息 (比如: 标题, 描述) 发生了变更"
- },
- "issue-comment-creation": {
- "title": "工单被评论",
- "label": "当新的工单评论被创建"
- },
"issue-approval-notify": {
"title": "工单待审批",
"label": "当工单需要审批"
},
- "notify-issue-approved": {
- "title": "工单审批通过",
- "label": "当工单审批通过"
+ "issue-sent-back": {
+ "title": "工单被退回",
+ "label": "当工单被审批人退回"
+ },
+ "pipeline-failed": {
+ "title": "流水线失败",
+ "label": "当流水线任务失败"
},
- "notify-pipeline-rollout": {
- "title": "工单待发布",
- "label": "当工单待发布时"
+ "pipeline-completed": {
+ "title": "流水线完成",
+ "label": "当流水线成功完成"
}
}
},
diff --git a/frontend/src/types/proto-es/v1/project_service_pb.d.ts b/frontend/src/types/proto-es/v1/project_service_pb.d.ts
index eccb180935..f245d7c79c 100644
--- a/frontend/src/types/proto-es/v1/project_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/project_service_pb.d.ts
@@ -785,15 +785,11 @@ export declare type Webhook = Message<"bytebase.v1.Webhook"> & {
* notification_types is the list of activities types that the webhook is interested in.
* Bytebase will only send notifications to the webhook if the activity type is in the list.
* It should not be empty, and should be a subset of the following:
- * - ISSUE_CREATE
- * - ISSUE_COMMENT_CREATE
- * - ISSUE_FIELD_UPDATE
- * - ISSUE_STATUS_UPDATE
- * - ISSUE_APPROVAL_NOTIFY
- * - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- * - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- * - NOTIFY_ISSUE_APPROVED
- * - NOTIFY_PIPELINE_ROLLOUT
+ * - ISSUE_CREATED
+ * - ISSUE_APPROVAL_REQUESTED
+ * - ISSUE_SENT_BACK
+ * - PIPELINE_FAILED
+ * - PIPELINE_COMPLETED
*
* @generated from field: repeated bytebase.v1.Activity.Type notification_types = 5;
*/
@@ -834,71 +830,39 @@ export enum Activity_Type {
TYPE_UNSPECIFIED = 0,
/**
- * Issue related activity types.
+ * ISSUE_CREATED represents a new issue creation event.
*
- * ISSUE_CREATE represents creating an issue.
- *
- * @generated from enum value: ISSUE_CREATE = 1;
- */
- ISSUE_CREATE = 1,
-
- /**
- * ISSUE_COMMENT_CREATE represents commenting on an issue.
- *
- * @generated from enum value: ISSUE_COMMENT_CREATE = 2;
- */
- ISSUE_COMMENT_CREATE = 2,
-
- /**
- * ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.
- *
- * @generated from enum value: ISSUE_FIELD_UPDATE = 3;
+ * @generated from enum value: ISSUE_CREATED = 10;
*/
- ISSUE_FIELD_UPDATE = 3,
+ ISSUE_CREATED = 10,
/**
- * ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL fow now.
+ * ISSUE_APPROVAL_REQUESTED represents an approval request event.
*
- * @generated from enum value: ISSUE_STATUS_UPDATE = 4;
+ * @generated from enum value: ISSUE_APPROVAL_REQUESTED = 11;
*/
- ISSUE_STATUS_UPDATE = 4,
+ ISSUE_APPROVAL_REQUESTED = 11,
/**
- * ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.
+ * ISSUE_SENT_BACK represents an issue being sent back by an approver.
*
- * @generated from enum value: ISSUE_PIPELINE_STAGE_STATUS_UPDATE = 5;
+ * @generated from enum value: ISSUE_SENT_BACK = 12;
*/
- ISSUE_PIPELINE_STAGE_STATUS_UPDATE = 5,
+ ISSUE_SENT_BACK = 12,
/**
- * ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.
- *
- * @generated from enum value: ISSUE_APPROVAL_NOTIFY = 6;
- */
- ISSUE_APPROVAL_NOTIFY = 6,
-
- /**
- * ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.
- *
- * @generated from enum value: ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE = 7;
- */
- ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE = 7,
-
- /**
- * Notifications via webhooks.
- *
- * NOTIFY_ISSUE_APPROVED represents the issue approved notification.
+ * PIPELINE_FAILED represents a pipeline failure event.
*
- * @generated from enum value: NOTIFY_ISSUE_APPROVED = 8;
+ * @generated from enum value: PIPELINE_FAILED = 13;
*/
- NOTIFY_ISSUE_APPROVED = 8,
+ PIPELINE_FAILED = 13,
/**
- * NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.
+ * PIPELINE_COMPLETED represents a pipeline completion event.
*
- * @generated from enum value: NOTIFY_PIPELINE_ROLLOUT = 9;
+ * @generated from enum value: PIPELINE_COMPLETED = 14;
*/
- NOTIFY_PIPELINE_ROLLOUT = 9,
+ PIPELINE_COMPLETED = 14,
}
/**
diff --git a/frontend/src/types/proto-es/v1/project_service_pb.js b/frontend/src/types/proto-es/v1/project_service_pb.js
index ddce93d51a..9045c8ea27 100644
--- a/frontend/src/types/proto-es/v1/project_service_pb.js
+++ b/frontend/src/types/proto-es/v1/project_service_pb.js
@@ -17,7 +17,7 @@ import { file_v1_iam_policy } from "./iam_policy_pb";
* Describes the file v1/project_service.proto.
*/
export const file_v1_project_service = /*@__PURE__*/
- fileDesc("Chh2MS9wcm9qZWN0X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIj8KEUdldFByb2plY3RSZXF1ZXN0EioKBG5hbWUYASABKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1Byb2plY3QiRgoXQmF0Y2hHZXRQcm9qZWN0c1JlcXVlc3QSKwoFbmFtZXMYASADKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1Byb2plY3QiQgoYQmF0Y2hHZXRQcm9qZWN0c1Jlc3BvbnNlEiYKCHByb2plY3RzGAEgAygLMhQuYnl0ZWJhc2UudjEuUHJvamVjdCJ0ChNMaXN0UHJvamVjdHNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEoBRISCgpwYWdlX3Rva2VuGAIgASgJEhQKDHNob3dfZGVsZXRlZBgDIAEoCBIOCgZmaWx0ZXIYBCABKAkSEAoIb3JkZXJfYnkYBSABKAkiVwoUTGlzdFByb2plY3RzUmVzcG9uc2USJgoIcHJvamVjdHMYASADKAsyFC5ieXRlYmFzZS52MS5Qcm9qZWN0EhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSJ2ChVTZWFyY2hQcm9qZWN0c1JlcXVlc3QSFAoMc2hvd19kZWxldGVkGAEgASgIEg4KBmZpbHRlchgCIAEoCRIRCglwYWdlX3NpemUYAyABKAUSEgoKcGFnZV90b2tlbhgEIAEoCRIQCghvcmRlcl9ieRgFIAEoCSJZChZTZWFyY2hQcm9qZWN0c1Jlc3BvbnNlEiYKCHByb2plY3RzGAEgAygLMhQuYnl0ZWJhc2UudjEuUHJvamVjdBIXCg9uZXh0X3BhZ2VfdG9rZW4YAiABKAkiVgoUQ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0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_v1_annotation, file_v1_common, file_v1_iam_policy]);
+ fileDesc("Chh2MS9wcm9qZWN0X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIj8KEUdldFByb2plY3RSZXF1ZXN0EioKBG5hbWUYASABKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1Byb2plY3QiRgoXQmF0Y2hHZXRQcm9qZWN0c1JlcXVlc3QSKwoFbmFtZXMYASADKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1Byb2plY3QiQgoYQmF0Y2hHZXRQcm9qZWN0c1Jlc3BvbnNlEiYKCHByb2plY3RzGAEgAygLMhQuYnl0ZWJhc2UudjEuUHJvamVjdCJ0ChNMaXN0UHJvamVjdHNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEoBRISCgpwYWdlX3Rva2VuGAIgASgJEhQKDHNob3dfZGVsZXRlZBgDIAEoCBIOCgZmaWx0ZXIYBCABKAkSEAoIb3JkZXJfYnkYBSABKAkiVwoUTGlzdFByb2plY3RzUmVzcG9uc2USJgoIcHJvamVjdHMYASADKAsyFC5ieXRlYmFzZS52MS5Qcm9qZWN0EhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSJ2ChVTZWFyY2hQcm9qZWN0c1JlcXVlc3QSFAoMc2hvd19kZWxldGVkGAEgASgIEg4KBmZpbHRlchgCIAEoCRIRCglwYWdlX3NpemUYAyABKAUSEgoKcGFnZV90b2tlbhgEIAEoCRIQCghvcmRlcl9ieRgFIAEoCSJZChZTZWFyY2hQcm9qZWN0c1Jlc3BvbnNlEiYKCHByb2plY3RzGAEgAygLMhQuYnl0ZWJhc2UudjEuUHJvamVjdBIXCg9uZXh0X3BhZ2VfdG9rZW4YAiABKAk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V2ViaG9vaxLBAQoNVXBkYXRlV2ViaG9vaxIhLmJ5dGViYXNlLnYxLlVwZGF0ZVdlYmhvb2tSZXF1ZXN0GhQuYnl0ZWJhc2UudjEuUHJvamVjdCJ32kETd2ViaG9vayx1cGRhdGVfbWFza4rqMBJiYi5wcm9qZWN0cy51cGRhdGWQ6jABgtPkkwJBOgd3ZWJob29rMjYvdjEve3dlYmhvb2submFtZT1wcm9qZWN0cy8qL3dlYmhvb2tzLyp9OnVwZGF0ZVdlYmhvb2sSpQEKDVJlbW92ZVdlYmhvb2sSIS5ieXRlYmFzZS52MS5SZW1vdmVXZWJob29rUmVxdWVzdBoULmJ5dGViYXNlLnYxLlByb2plY3QiW4rqMBJiYi5wcm9qZWN0cy51cGRhdGWQ6jABgtPkkwI7OgEqIjYvdjEve3dlYmhvb2submFtZT1wcm9qZWN0cy8qL3dlYmhvb2tzLyp9OnJlbW92ZVdlYmhvb2sSmwEKC1Rlc3RXZWJob29rEh8uYnl0ZWJhc2UudjEuVGVzdFdlYmhvb2tSZXF1ZXN0GiAuYnl0ZWJhc2UudjEuVGVzdFdlYmhvb2tSZXNwb25zZSJJiuowEmJiLnByb2plY3RzLnVwZGF0ZZDqMAGC0+STAik6ASoiJC92MS97cHJvamVjdD1wcm9qZWN0cy8qfTp0ZXN0V2ViaG9va0KpAQoPY29tLmJ5dGViYXNlLnYxQhNQcm9qZWN0U2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_v1_annotation, file_v1_common, file_v1_iam_policy]);
/**
* Describes the message bytebase.v1.GetProjectRequest.
diff --git a/frontend/src/types/v1/projectWebhook.ts b/frontend/src/types/v1/projectWebhook.ts
index 56e30b8ccc..0ec701795c 100644
--- a/frontend/src/types/v1/projectWebhook.ts
+++ b/frontend/src/types/v1/projectWebhook.ts
@@ -9,7 +9,7 @@ import {
export const emptyProjectWebhook = () => {
return createProto(WebhookSchema, {
type: WebhookType.SLACK,
- notificationTypes: [Activity_Type.ISSUE_STATUS_UPDATE],
+ notificationTypes: [Activity_Type.ISSUE_CREATED],
});
};
@@ -101,64 +101,32 @@ export const projectWebhookV1ActivityItemList =
{
title: t("project.webhook.activity-item.issue-creation.title"),
label: t("project.webhook.activity-item.issue-creation.label"),
- activity: Activity_Type.ISSUE_CREATE,
- supportDirectMessage: false,
- },
- {
- title: t("project.webhook.activity-item.issue-status-change.title"),
- label: t("project.webhook.activity-item.issue-status-change.label"),
- activity: Activity_Type.ISSUE_STATUS_UPDATE,
- supportDirectMessage: false,
- },
- {
- title: t(
- "project.webhook.activity-item.issue-stage-status-change.title"
- ),
- label: t(
- "project.webhook.activity-item.issue-stage-status-change.label"
- ),
- activity: Activity_Type.ISSUE_PIPELINE_STAGE_STATUS_UPDATE,
- supportDirectMessage: false,
- },
- {
- title: t(
- "project.webhook.activity-item.issue-task-status-change.title"
- ),
- label: t(
- "project.webhook.activity-item.issue-task-status-change.label"
- ),
- activity: Activity_Type.ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE,
- supportDirectMessage: false,
- },
- {
- title: t("project.webhook.activity-item.issue-info-change.title"),
- label: t("project.webhook.activity-item.issue-info-change.label"),
- activity: Activity_Type.ISSUE_FIELD_UPDATE,
- supportDirectMessage: false,
- },
- {
- title: t("project.webhook.activity-item.issue-comment-creation.title"),
- label: t("project.webhook.activity-item.issue-comment-creation.label"),
- activity: Activity_Type.ISSUE_COMMENT_CREATE,
+ activity: Activity_Type.ISSUE_CREATED,
supportDirectMessage: false,
},
{
title: t("project.webhook.activity-item.issue-approval-notify.title"),
label: t("project.webhook.activity-item.issue-approval-notify.label"),
- activity: Activity_Type.ISSUE_APPROVAL_NOTIFY,
+ activity: Activity_Type.ISSUE_APPROVAL_REQUESTED,
supportDirectMessage: true,
},
{
- title: t("project.webhook.activity-item.notify-issue-approved.title"),
- label: t("project.webhook.activity-item.notify-issue-approved.label"),
- activity: Activity_Type.NOTIFY_ISSUE_APPROVED,
+ title: t("project.webhook.activity-item.issue-sent-back.title"),
+ label: t("project.webhook.activity-item.issue-sent-back.label"),
+ activity: Activity_Type.ISSUE_SENT_BACK,
supportDirectMessage: true,
},
{
- title: t("project.webhook.activity-item.notify-pipeline-rollout.title"),
- label: t("project.webhook.activity-item.notify-pipeline-rollout.label"),
- activity: Activity_Type.NOTIFY_PIPELINE_ROLLOUT,
- supportDirectMessage: true,
+ title: t("project.webhook.activity-item.pipeline-failed.title"),
+ label: t("project.webhook.activity-item.pipeline-failed.label"),
+ activity: Activity_Type.PIPELINE_FAILED,
+ supportDirectMessage: false,
+ },
+ {
+ title: t("project.webhook.activity-item.pipeline-completed.title"),
+ label: t("project.webhook.activity-item.pipeline-completed.label"),
+ activity: Activity_Type.PIPELINE_COMPLETED,
+ supportDirectMessage: false,
},
];
};
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index c50dc26cc7..bd71f0fa03 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -15022,30 +15022,22 @@ components:
items:
enum:
- TYPE_UNSPECIFIED
- - ISSUE_CREATE
- - ISSUE_COMMENT_CREATE
- - ISSUE_FIELD_UPDATE
- - ISSUE_STATUS_UPDATE
- - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- - ISSUE_APPROVAL_NOTIFY
- - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- - NOTIFY_ISSUE_APPROVED
- - NOTIFY_PIPELINE_ROLLOUT
+ - ISSUE_CREATED
+ - ISSUE_APPROVAL_REQUESTED
+ - ISSUE_SENT_BACK
+ - PIPELINE_FAILED
+ - PIPELINE_COMPLETED
type: string
format: enum
description: |-
notification_types is the list of activities types that the webhook is interested in.
Bytebase will only send notifications to the webhook if the activity type is in the list.
It should not be empty, and should be a subset of the following:
- - ISSUE_CREATE
- - ISSUE_COMMENT_CREATE
- - ISSUE_FIELD_UPDATE
- - ISSUE_STATUS_UPDATE
- - ISSUE_APPROVAL_NOTIFY
- - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- - NOTIFY_ISSUE_APPROVED
- - NOTIFY_PIPELINE_ROLLOUT
+ - ISSUE_CREATED
+ - ISSUE_APPROVAL_REQUESTED
+ - ISSUE_SENT_BACK
+ - PIPELINE_FAILED
+ - PIPELINE_COMPLETED
WorkloadIdentityConfig:
type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 337ca0e639..18bb972127 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -3546,19 +3546,11 @@ Activity type enumeration.
| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_UNSPECIFIED | 0 | Unspecified type. |
-| ISSUE_CREATE | 1 | Issue related activity types.
-
-ISSUE_CREATE represents creating an issue. |
-| ISSUE_COMMENT_CREATE | 2 | ISSUE_COMMENT_CREATE represents commenting on an issue. |
-| ISSUE_FIELD_UPDATE | 3 | ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc. |
-| ISSUE_STATUS_UPDATE | 4 | ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL for now. |
-| ISSUE_PIPELINE_STAGE_STATUS_UPDATE | 5 | ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now. |
-| ISSUE_APPROVAL_NOTIFY | 6 | ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval. |
-| ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE | 7 | ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED. |
-| NOTIFY_ISSUE_APPROVED | 8 | Notifications via webhooks.
-
-NOTIFY_ISSUE_APPROVED represents the issue approved notification. |
-| NOTIFY_PIPELINE_ROLLOUT | 9 | NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification. |
+| ISSUE_CREATED | 10 | ISSUE_CREATED represents a new issue creation event. |
+| ISSUE_APPROVAL_REQUESTED | 11 | ISSUE_APPROVAL_REQUESTED represents an approval request event. |
+| ISSUE_SENT_BACK | 12 | ISSUE_SENT_BACK represents an issue being sent back by an approver. |
+| PIPELINE_FAILED | 13 | PIPELINE_FAILED represents a pipeline failure event. |
+| PIPELINE_COMPLETED | 14 | PIPELINE_COMPLETED represents a pipeline completion event. |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 296ff27ea1..238dc42c08 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -9833,61 +9833,33 @@ IM integration setting should be set for this function to work. </p></td>
</tr>
<tr>
- <td>ISSUE_CREATE</td>
- <td>1</td>
- <td><p>Issue related activity types.
-
-ISSUE_CREATE represents creating an issue.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_COMMENT_CREATE</td>
- <td>2</td>
- <td><p>ISSUE_COMMENT_CREATE represents commenting on an issue.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_FIELD_UPDATE</td>
- <td>3</td>
- <td><p>ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_STATUS_UPDATE</td>
- <td>4</td>
- <td><p>ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL for now.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_PIPELINE_STAGE_STATUS_UPDATE</td>
- <td>5</td>
- <td><p>ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.</p></td>
+ <td>ISSUE_CREATED</td>
+ <td>10</td>
+ <td><p>ISSUE_CREATED represents a new issue creation event.</p></td>
</tr>
<tr>
- <td>ISSUE_APPROVAL_NOTIFY</td>
- <td>6</td>
- <td><p>ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.</p></td>
+ <td>ISSUE_APPROVAL_REQUESTED</td>
+ <td>11</td>
+ <td><p>ISSUE_APPROVAL_REQUESTED represents an approval request event.</p></td>
</tr>
<tr>
- <td>ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE</td>
- <td>7</td>
- <td><p>ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.</p></td>
+ <td>ISSUE_SENT_BACK</td>
+ <td>12</td>
+ <td><p>ISSUE_SENT_BACK represents an issue being sent back by an approver.</p></td>
</tr>
<tr>
- <td>NOTIFY_ISSUE_APPROVED</td>
- <td>8</td>
- <td><p>Notifications via webhooks.
-
-NOTIFY_ISSUE_APPROVED represents the issue approved notification.</p></td>
+ <td>PIPELINE_FAILED</td>
+ <td>13</td>
+ <td><p>PIPELINE_FAILED represents a pipeline failure event.</p></td>
</tr>
<tr>
- <td>NOTIFY_PIPELINE_ROLLOUT</td>
- <td>9</td>
- <td><p>NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.</p></td>
+ <td>PIPELINE_COMPLETED</td>
+ <td>14</td>
+ <td><p>PIPELINE_COMPLETED represents a pipeline completion event.</p></td>
</tr>
</tbody>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 3a7d4a1a3f..79dd90f267 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -8218,7 +8218,7 @@ The project&#39;s `name` field is used to identify the project to update. Format
| title | [string](#string) | | title is the title of the webhook. |
| url | [string](#string) | | url is the url of the webhook, should be unique within the project. |
| direct_message | [bool](#bool) | | if direct_message is set, the notification is sent directly to the persons and url will be ignored. IM integration setting should be set for this function to work. |
-| notification_types | [Activity.Type](#bytebase-v1-Activity-Type) | repeated | notification_types is the list of activities types that the webhook is interested in. Bytebase will only send notifications to the webhook if the activity type is in the list. It should not be empty, and should be a subset of the following: - ISSUE_CREATE - ISSUE_COMMENT_CREATE - ISSUE_FIELD_UPDATE - ISSUE_STATUS_UPDATE - ISSUE_APPROVAL_NOTIFY - ISSUE_PIPELINE_STAGE_STATUS_UPDATE - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE - NOTIFY_ISSUE_APPROVED - NOTIFY_PIPELINE_ROLLOUT |
+| notification_types | [Activity.Type](#bytebase-v1-Activity-Type) | repeated | notification_types is the list of activities types that the webhook is interested in. Bytebase will only send notifications to the webhook if the activity type is in the list. It should not be empty, and should be a subset of the following: - ISSUE_CREATED - ISSUE_APPROVAL_REQUESTED - ISSUE_SENT_BACK - PIPELINE_FAILED - PIPELINE_COMPLETED |
@@ -8235,19 +8235,11 @@ Activity type enumeration.
| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_UNSPECIFIED | 0 | Unspecified type. |
-| ISSUE_CREATE | 1 | Issue related activity types.
-
-ISSUE_CREATE represents creating an issue. |
-| ISSUE_COMMENT_CREATE | 2 | ISSUE_COMMENT_CREATE represents commenting on an issue. |
-| ISSUE_FIELD_UPDATE | 3 | ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc. |
-| ISSUE_STATUS_UPDATE | 4 | ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL fow now. |
-| ISSUE_PIPELINE_STAGE_STATUS_UPDATE | 5 | ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now. |
-| ISSUE_APPROVAL_NOTIFY | 6 | ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval. |
-| ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE | 7 | ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED. |
-| NOTIFY_ISSUE_APPROVED | 8 | Notifications via webhooks.
-
-NOTIFY_ISSUE_APPROVED represents the issue approved notification. |
-| NOTIFY_PIPELINE_ROLLOUT | 9 | NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification. |
+| ISSUE_CREATED | 10 | ISSUE_CREATED represents a new issue creation event. |
+| ISSUE_APPROVAL_REQUESTED | 11 | ISSUE_APPROVAL_REQUESTED represents an approval request event. |
+| ISSUE_SENT_BACK | 12 | ISSUE_SENT_BACK represents an issue being sent back by an approver. |
+| PIPELINE_FAILED | 13 | PIPELINE_FAILED represents a pipeline failure event. |
+| PIPELINE_COMPLETED | 14 | PIPELINE_COMPLETED represents a pipeline completion event. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 1cdc8b5041..cac7ba18a8 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -23027,15 +23027,11 @@ IM integration setting should be set for this function to work. </p></td>
<td><p>notification_types is the list of activities types that the webhook is interested in.
Bytebase will only send notifications to the webhook if the activity type is in the list.
It should not be empty, and should be a subset of the following:
-- ISSUE_CREATE
-- ISSUE_COMMENT_CREATE
-- ISSUE_FIELD_UPDATE
-- ISSUE_STATUS_UPDATE
-- ISSUE_APPROVAL_NOTIFY
-- ISSUE_PIPELINE_STAGE_STATUS_UPDATE
-- ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
-- NOTIFY_ISSUE_APPROVED
-- NOTIFY_PIPELINE_ROLLOUT </p></td>
+- ISSUE_CREATED
+- ISSUE_APPROVAL_REQUESTED
+- ISSUE_SENT_BACK
+- PIPELINE_FAILED
+- PIPELINE_COMPLETED </p></td>
</tr>
</tbody>
@@ -23062,61 +23058,33 @@ It should not be empty, and should be a subset of the following:
</tr>
<tr>
- <td>ISSUE_CREATE</td>
- <td>1</td>
- <td><p>Issue related activity types.
-
-ISSUE_CREATE represents creating an issue.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_COMMENT_CREATE</td>
- <td>2</td>
- <td><p>ISSUE_COMMENT_CREATE represents commenting on an issue.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_FIELD_UPDATE</td>
- <td>3</td>
- <td><p>ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_STATUS_UPDATE</td>
- <td>4</td>
- <td><p>ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL fow now.</p></td>
- </tr>
-
- <tr>
- <td>ISSUE_PIPELINE_STAGE_STATUS_UPDATE</td>
- <td>5</td>
- <td><p>ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.</p></td>
+ <td>ISSUE_CREATED</td>
+ <td>10</td>
+ <td><p>ISSUE_CREATED represents a new issue creation event.</p></td>
</tr>
<tr>
- <td>ISSUE_APPROVAL_NOTIFY</td>
- <td>6</td>
- <td><p>ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.</p></td>
+ <td>ISSUE_APPROVAL_REQUESTED</td>
+ <td>11</td>
+ <td><p>ISSUE_APPROVAL_REQUESTED represents an approval request event.</p></td>
</tr>
<tr>
- <td>ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE</td>
- <td>7</td>
- <td><p>ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.</p></td>
+ <td>ISSUE_SENT_BACK</td>
+ <td>12</td>
+ <td><p>ISSUE_SENT_BACK represents an issue being sent back by an approver.</p></td>
</tr>
<tr>
- <td>NOTIFY_ISSUE_APPROVED</td>
- <td>8</td>
- <td><p>Notifications via webhooks.
-
-NOTIFY_ISSUE_APPROVED represents the issue approved notification.</p></td>
+ <td>PIPELINE_FAILED</td>
+ <td>13</td>
+ <td><p>PIPELINE_FAILED represents a pipeline failure event.</p></td>
</tr>
<tr>
- <td>NOTIFY_PIPELINE_ROLLOUT</td>
- <td>9</td>
- <td><p>NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.</p></td>
+ <td>PIPELINE_COMPLETED</td>
+ <td>14</td>
+ <td><p>PIPELINE_COMPLETED represents a pipeline completion event.</p></td>
</tr>
</tbody>
diff --git a/proto/store/store/project_webhook.proto b/proto/store/store/project_webhook.proto
index e7de54c0ae..e6b109dfe9 100644
--- a/proto/store/store/project_webhook.proto
+++ b/proto/store/store/project_webhook.proto
@@ -12,28 +12,16 @@ message Activity {
enum Type {
// Unspecified type.
TYPE_UNSPECIFIED = 0;
- // Issue related activity types.
- //
- // ISSUE_CREATE represents creating an issue.
- ISSUE_CREATE = 1;
- // ISSUE_COMMENT_CREATE represents commenting on an issue.
- ISSUE_COMMENT_CREATE = 2;
- // ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.
- ISSUE_FIELD_UPDATE = 3;
- // ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL for now.
- ISSUE_STATUS_UPDATE = 4;
- // ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.
- ISSUE_PIPELINE_STAGE_STATUS_UPDATE = 5;
- // ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.
- ISSUE_APPROVAL_NOTIFY = 6;
- // ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.
- ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE = 7;
- // Notifications via webhooks.
- //
- // NOTIFY_ISSUE_APPROVED represents the issue approved notification.
- NOTIFY_ISSUE_APPROVED = 8;
- // NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.
- NOTIFY_PIPELINE_ROLLOUT = 9;
+ // ISSUE_CREATED represents a new issue creation event.
+ ISSUE_CREATED = 10;
+ // ISSUE_APPROVAL_REQUESTED represents an approval request event.
+ ISSUE_APPROVAL_REQUESTED = 11;
+ // ISSUE_SENT_BACK represents an issue being sent back by an approver.
+ ISSUE_SENT_BACK = 12;
+ // PIPELINE_FAILED represents a pipeline failure event.
+ PIPELINE_FAILED = 13;
+ // PIPELINE_COMPLETED represents a pipeline completion event.
+ PIPELINE_COMPLETED = 14;
}
}
diff --git a/proto/v1/v1/project_service.proto b/proto/v1/v1/project_service.proto
index ef1c7915e7..3a7e337103 100644
--- a/proto/v1/v1/project_service.proto
+++ b/proto/v1/v1/project_service.proto
@@ -535,15 +535,11 @@ message Webhook {
// notification_types is the list of activities types that the webhook is interested in.
// Bytebase will only send notifications to the webhook if the activity type is in the list.
// It should not be empty, and should be a subset of the following:
- // - ISSUE_CREATE
- // - ISSUE_COMMENT_CREATE
- // - ISSUE_FIELD_UPDATE
- // - ISSUE_STATUS_UPDATE
- // - ISSUE_APPROVAL_NOTIFY
- // - ISSUE_PIPELINE_STAGE_STATUS_UPDATE
- // - ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE
- // - NOTIFY_ISSUE_APPROVED
- // - NOTIFY_PIPELINE_ROLLOUT
+ // - ISSUE_CREATED
+ // - ISSUE_APPROVAL_REQUESTED
+ // - ISSUE_SENT_BACK
+ // - PIPELINE_FAILED
+ // - PIPELINE_COMPLETED
repeated Activity.Type notification_types = 5 [(google.api.field_behavior) = UNORDERED_LIST];
}
@@ -553,27 +549,15 @@ message Activity {
enum Type {
// Unspecified type.
TYPE_UNSPECIFIED = 0;
- // Issue related activity types.
- //
- // ISSUE_CREATE represents creating an issue.
- ISSUE_CREATE = 1;
- // ISSUE_COMMENT_CREATE represents commenting on an issue.
- ISSUE_COMMENT_CREATE = 2;
- // ISSUE_FIELD_UPDATE represents updating the issue field, likes title, description, etc.
- ISSUE_FIELD_UPDATE = 3;
- // ISSUE_STATUS_UPDATE represents the issue status change, including OPEN, CLOSE, CANCEL fow now.
- ISSUE_STATUS_UPDATE = 4;
- // ISSUE_PIPELINE_STAGE_STATUS_UPDATE represents the pipeline stage status change, including BEGIN, END for now.
- ISSUE_PIPELINE_STAGE_STATUS_UPDATE = 5;
- // ISSUE_APPROVAL_NOTIFY is the type for notifying issue approval.
- ISSUE_APPROVAL_NOTIFY = 6;
- // ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE represents the pipeline task run status change, including PENDING, RUNNING, DONE, FAILED, CANCELED.
- ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE = 7;
- // Notifications via webhooks.
- //
- // NOTIFY_ISSUE_APPROVED represents the issue approved notification.
- NOTIFY_ISSUE_APPROVED = 8;
- // NOTIFY_PIPELINE_ROLLOUT represents the pipeline rollout notification.
- NOTIFY_PIPELINE_ROLLOUT = 9;
+ // ISSUE_CREATED represents a new issue creation event.
+ ISSUE_CREATED = 10;
+ // ISSUE_APPROVAL_REQUESTED represents an approval request event.
+ ISSUE_APPROVAL_REQUESTED = 11;
+ // ISSUE_SENT_BACK represents an issue being sent back by an approver.
+ ISSUE_SENT_BACK = 12;
+ // PIPELINE_FAILED represents a pipeline failure event.
+ PIPELINE_FAILED = 13;
+ // PIPELINE_COMPLETED represents a pipeline completion event.
+ PIPELINE_COMPLETED = 14;
}
}