Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add Environment into webhook message (#19543)
longqmcebc80278517
diff --git a/backend/component/webhook/event.go b/backend/component/webhook/event.goindex 5cc06fc321..3503c14b67 100644--- a/backend/component/webhook/event.go+++ b/backend/component/webhook/event.go@@ -85,11 +85,13 @@ type EventIssueSentBack struct {}type EventRolloutFailed struct {- Rollout *Rollout+ Rollout *Rollout+ Environment string}type EventRolloutCompleted struct {- Rollout *Rollout+ Rollout *Rollout+ Environment string}type User struct {diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.goindex d880cdf1a2..e84ffe2612 100644--- a/backend/component/webhook/manager.go+++ b/backend/component/webhook/manager.go@@ -133,6 +133,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenrollout = e.RolloutFailed.Rolloutlink = fmt.Sprintf("%s/projects/%s/plans/%d/rollout", externalURL, e.Project.ResourceID, rollout.UID)webhookCtx.Description = "Rollout failed"+ webhookCtx.Environment = e.RolloutFailed.Environment}case storepb.Activity_PIPELINE_COMPLETED:@@ -143,6 +144,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenrollout = e.RolloutCompleted.Rolloutlink = fmt.Sprintf("%s/projects/%s/plans/%d/rollout", externalURL, e.Project.ResourceID, rollout.UID)webhookCtx.Description = "Rollout completed successfully"+ webhookCtx.Environment = e.RolloutCompleted.Environment}default:diff --git a/backend/plugin/webhook/webhook.go b/backend/plugin/webhook/webhook.goindex 1e3f44463a..9049c87dca 100644--- a/backend/plugin/webhook/webhook.go+++ b/backend/plugin/webhook/webhook.go@@ -91,6 +91,9 @@ type Context struct {// Event-specific dataFailedTasks []FailedTaskInfo++ // Environment is the environment resource ID (e.g., "environments/prod").+ Environment string}// FailedTaskInfo contains information about a failed task.@@ -140,6 +143,12 @@ func (c *Context) GetMetaList() []Meta {Value: c.Rollout.Title,})}+ if c.Environment != "" {+ m = append(m, Meta{+ Name: "Environment",+ Value: c.Environment,+ })+ }}return m@@ -178,6 +187,12 @@ func (c *Context) GetMetaListZh() []Meta {Value: c.Rollout.Title,})}+ if c.Environment != "" {+ m = append(m, Meta{+ Name: "环境",+ Value: c.Environment,+ })+ }}return mdiff --git a/backend/runner/taskrun/running_scheduler.go b/backend/runner/taskrun/running_scheduler.goindex 9055a31bd8..2d8472357c 100644--- a/backend/runner/taskrun/running_scheduler.go+++ b/backend/runner/taskrun/running_scheduler.go@@ -193,7 +193,8 @@ func (s *Scheduler) runTaskRunOnce(ctx context.Context, taskRunUID int, task *stType: storepb.Activity_PIPELINE_FAILED,Project: webhook.NewProject(project),RolloutFailed: &webhook.EventRolloutFailed{- Rollout: webhook.NewRollout(plan),+ Rollout: webhook.NewRollout(plan),+ Environment: task.Environment,},})}diff --git a/backend/runner/taskrun/scheduler.go b/backend/runner/taskrun/scheduler.goindex 8a7beecb8d..5e066516d2 100644--- a/backend/runner/taskrun/scheduler.go+++ b/backend/runner/taskrun/scheduler.go@@ -150,12 +150,19 @@ func (s *Scheduler) checkPlanCompletion(ctx context.Context, planID int64) {return}+ // Use environment from the first task (all tasks should be in the same environment for a rollout)+ environment := ""+ if len(tasks) > 0 {+ environment = tasks[0].Environment+ }+// Send PIPELINE_COMPLETED webhooks.webhookManager.CreateEvent(ctx, &webhook.Event{Type: storepb.Activity_PIPELINE_COMPLETED,Project: webhook.NewProject(project),RolloutCompleted: &webhook.EventRolloutCompleted{- Rollout: webhook.NewRollout(plan),+ Rollout: webhook.NewRollout(plan),+ Environment: environment,},})