Skip to content

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

chore: webhook event (#11351)

Danny Xu413e080c0158
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 9f73bc31d2..b85a037bd6 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -2428,8 +2428,10 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoi
webhookCreate := gitlab.WebhookCreate{
URL: fmt.Sprintf("%s/hook/%s", bytebaseEndpointURL, webhookEndpointID),
SecretToken: secretToken,
+ MergeRequestsEvents: true,
PushEvents: true,
- EnableSSLVerification: false, // TODO(tianzhou): This is set to false, be lax to not enable_ssl_verification
+ NoteEvents: true,
+ EnableSSLVerification: false,
}
webhookCreatePayload, err = json.Marshal(webhookCreate)
if err != nil {
@@ -2441,9 +2443,9 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoi
URL: fmt.Sprintf("%s/hook/%s", bytebaseEndpointURL, webhookEndpointID),
ContentType: "json",
Secret: secretToken,
- InsecureSSL: 1, // TODO: Allow user to specify this value through api.RepositoryCreate
+ InsecureSSL: 1,
},
- Events: []string{"push"},
+ Events: []string{"push", "pull_request", "pull_request_review_comment"},
}
webhookCreatePayload, err = json.Marshal(webhookPost)
if err != nil {
@@ -2454,7 +2456,7 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoi
Description: "Bytebase GitOps",
URL: fmt.Sprintf("%s/hook/%s", bytebaseEndpointURL, webhookEndpointID),
Active: true,
- Events: []string{"repo:push"},
+ Events: []string{"repo:push", "pullrequest:created", "pullrequest:updated", "pullrequest:comment_created"},
}
webhookCreatePayload, err = json.Marshal(webhookPost)
if err != nil {
@@ -2474,7 +2476,8 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoi
URL: fmt.Sprintf("%s/hook/%s", bytebaseEndpointURL, webhookEndpointID),
AcceptUntrustedCerts: true,
},
- EventType: "git.push",
+ EventType: "git.push",
+ // TODO(d): We cannot create a few webhooks together with "git.pullrequest.created", "git.pullrequest.updated", and work items.
PublisherID: "tfs",
PublisherInputs: azure.WebhookCreatePublisherInputs{
Repository: repositoryID,
diff --git a/backend/plugin/vcs/gitlab/gitlab.go b/backend/plugin/vcs/gitlab/gitlab.go
index 209bc6c694..1fa9f0380d 100644
--- a/backend/plugin/vcs/gitlab/gitlab.go
+++ b/backend/plugin/vcs/gitlab/gitlab.go
@@ -48,7 +48,9 @@ type WebhookCreate struct {
URL string `json:"url"`
SecretToken string `json:"token"`
// This is set to true
- PushEvents bool `json:"push_events"`
+ PushEvents bool `json:"push_events"`
+ NoteEvents bool `json:"note_events"`
+ MergeRequestsEvents bool `json:"merge_requests_events"`
// For now, there is no native dry run DDL support in mysql/postgres. One may wonder if we could wrap the DDL
// in a transaction and just not commit at the end, unfortunately there are side effects which are hard to control.
// See https://www.postgresql.org/message-id/CAMsr%2BYGiYQ7PYvYR2Voio37YdCpp79j5S%2BcmgVJMOLM2LnRQcA%40mail.gmail.com