Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: support setup bitbucket ci in dev (#10804)
ecmadaoa533f060de10
diff --git a/backend/api/gitops/webhook.go b/backend/api/gitops/webhook.goindex 8747115502..e0cebe9725 100644--- a/backend/api/gitops/webhook.go+++ b/backend/api/gitops/webhook.go@@ -721,6 +721,8 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {response = convertSQLAdviceToGitLabCIResult(sqlFileName2Advice)case vcs.AzureDevOps:response = convertSQLAdviceToGitLabCIResult(sqlFileName2Advice)+ case vcs.Bitbucket:+ response = convertSQLAdviceToGitLabCIResult(sqlFileName2Advice)}slog.Debug("SQL review finished",diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex c9aea0a781..c76bd3b407 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -1241,15 +1241,19 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *stswitch vcs.Type {case vcsplugin.GitHub:- if err := s.setupVCSSQLReviewCIForGitHub(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {+ if err := setupVCSSQLReviewCIForGitHub(ctx, oauthContext, repository, vcs, branch, sqlReviewEndpoint); err != nil {return nil, err}case vcsplugin.GitLab:- if err := s.setupVCSSQLReviewCIForGitLab(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {+ if err := setupVCSSQLReviewCIForGitLab(ctx, oauthContext, repository, vcs, branch, sqlReviewEndpoint); err != nil {return nil, err}case vcsplugin.AzureDevOps:- if err := s.setupVCSSQLReviewCIForAzureDevOps(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {+ if err := setupVCSSQLReviewCIForAzureDevOps(ctx, oauthContext, repository, vcs, branch, sqlReviewEndpoint); err != nil {+ return nil, err+ }+ case vcsplugin.Bitbucket:+ if err := setupVCSSQLReviewCIForBitBucket(ctx, oauthContext, repository, vcs, branch, sqlReviewEndpoint, repository.WebhookSecretToken); err != nil {return nil, err}}@@ -1316,8 +1320,9 @@ func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repository}// setupVCSSQLReviewCIForGitHub will create the pull request in GitHub to setup SQL review action.-func (s *ProjectService) setupVCSSQLReviewCIForGitHub(+func setupVCSSQLReviewCIForGitHub(ctx context.Context,+ oauthContext *common.OauthContext,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,branch *vcsplugin.BranchInfo,@@ -1327,22 +1332,6 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(fileLastCommitID := ""fileSHA := ""- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())- }- if setting.ExternalUrl == "" {- return status.Errorf(codes.FailedPrecondition, "external url is required")- }-- oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),- }fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,oauthContext,@@ -1383,32 +1372,22 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub()}-// setupVCSSQLReviewCIForGitLab will create or update SQL review related files in GitLab to setup SQL review CI.-func (s *ProjectService) setupVCSSQLReviewCIForGitLab(+func setupVCSSQLReviewCIForBitBucket(ctx context.Context,+ oauthContext *common.OauthContext,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,branch *vcsplugin.BranchInfo,sqlReviewEndpoint string,+ sqlReviewSecret string,) error {- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())- }- if setting.ExternalUrl == "" {- return status.Errorf(codes.FailedPrecondition, "external url is required")+ if err := createOrUpdateVCSSQLReviewFile(ctx, oauthContext, repository, vcs, branch, bitbucket.SQLReviewScriptFilePath, func(_ *vcsplugin.FileMeta) (string, error) {+ return bitbucket.SQLReviewScript, nil+ }); err != nil {+ return err}- oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),- }- // create or update the .gitlab-ci.yml- if err := s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.CIFilePath, func(fileMeta *vcsplugin.FileMeta) (string, error) {+ return createOrUpdateVCSSQLReviewFile(ctx, oauthContext, repository, vcs, branch, bitbucket.CIFilePath, func(fileMeta *vcsplugin.FileMeta) (string, error) {content := make(map[string]any)if fileMeta != nil {@@ -1417,7 +1396,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(oauthContext,vcs.InstanceURL,repository.ExternalID,- gitlab.CIFilePath,+ bitbucket.CIFilePath,vcsplugin.RefInfo{RefType: vcsplugin.RefTypeCommit,RefName: fileMeta.LastCommitID,@@ -1431,25 +1410,68 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(}}- newContent, err := gitlab.SetupGitLabCI(content)+ newContent, err := bitbucket.SetupBitBucketCI(content, sqlReviewEndpoint, sqlReviewSecret)if err != nil {return "", err}return newContent, nil+ })+}++// setupVCSSQLReviewCIForGitLab will create or update SQL review related files in GitLab to setup SQL review CI.+func setupVCSSQLReviewCIForGitLab(+ ctx context.Context,+ oauthContext *common.OauthContext,+ repository *store.RepositoryMessage,+ vcs *store.ExternalVersionControlMessage,+ branch *vcsplugin.BranchInfo,+ sqlReviewEndpoint string,+) error {+ // create or update the SQL review CI.+ if err := createOrUpdateVCSSQLReviewFile(ctx, oauthContext, repository, vcs, branch, gitlab.SQLReviewCIFilePath, func(_ *vcsplugin.FileMeta) (string, error) {+ return gitlab.SetupSQLReviewCI(sqlReviewEndpoint), nil}); err != nil {return err}- // create or update the SQL review CI.- return s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.SQLReviewCIFilePath, func(_ *vcsplugin.FileMeta) (string, error) {- return gitlab.SetupSQLReviewCI(sqlReviewEndpoint), nil+ // create or update the .gitlab-ci.yml+ return createOrUpdateVCSSQLReviewFile(ctx, oauthContext, repository, vcs, branch, gitlab.CIFilePath, func(fileMeta *vcsplugin.FileMeta) (string, error) {+ content := make(map[string]any)++ if fileMeta != nil {+ ciFileContent, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileContent(+ ctx,+ oauthContext,+ vcs.InstanceURL,+ repository.ExternalID,+ gitlab.CIFilePath,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeCommit,+ RefName: fileMeta.LastCommitID,+ },+ )+ if err != nil {+ return "", err+ }+ if err := yaml.Unmarshal([]byte(ciFileContent), &content); err != nil {+ return "", err+ }+ }++ newContent, err := gitlab.SetupGitLabCI(content)+ if err != nil {+ return "", err+ }++ return newContent, nil})}// setupVCSSQLReviewCIForAzureDevOps will create or update SQL review related files in Azure DevOps to setup SQL review CI.-func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(+func setupVCSSQLReviewCIForAzureDevOps(ctx context.Context,+ oauthContext *common.OauthContext,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,branch *vcsplugin.BranchInfo,@@ -1459,23 +1481,6 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(fileLastCommitID := ""fileSHA := ""- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())- }- if setting.ExternalUrl == "" {- return status.Errorf(codes.FailedPrecondition, "external url is required")- }-- oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),- }-fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,oauthContext,@@ -1516,31 +1521,16 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps()}-// createOrUpdateVCSSQLReviewFileForGitLab will create or update SQL review file for GitLab CI.-func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(+// createOrUpdateVCSSQLReviewFile will create or update SQL review file for GitLab or BitBucket.+func createOrUpdateVCSSQLReviewFile(ctx context.Context,+ oauthContext *common.OauthContext,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,branch *vcsplugin.BranchInfo,fileName string,getNewContent func(meta *vcsplugin.FileMeta) (string, error),) error {- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())- }- if setting.ExternalUrl == "" {- return status.Errorf(codes.FailedPrecondition, "external url is required")- }- oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),- }-fileExisted := truefileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,diff --git a/backend/plugin/vcs/bitbucket/bitbucket.go b/backend/plugin/vcs/bitbucket/bitbucket.goindex fa6bbbe524..9d0991bec1 100644--- a/backend/plugin/vcs/bitbucket/bitbucket.go+++ b/backend/plugin/vcs/bitbucket/bitbucket.go@@ -853,9 +853,10 @@ func (p *Provider) CreatePullRequest(ctx context.Context, oauthCtx *common.Oauth// UpsertEnvironmentVariable creates or updates the environment variable in the repository.//+// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-variables-post// WARNING: This is not supported in Bitbucket Cloud.func (*Provider) UpsertEnvironmentVariable(context.Context, *common.OauthContext, string, string, string, string) error {- return errors.New("not supported")+ return nil}// Link is the API message for link.diff --git a/backend/plugin/vcs/bitbucket/bytebase-sql-review.sh b/backend/plugin/vcs/bitbucket/bytebase-sql-review.shnew file mode 100644index 0000000000..d418827f92--- /dev/null+++ b/backend/plugin/vcs/bitbucket/bytebase-sql-review.sh@@ -0,0 +1,58 @@+#!/bin/bash+# ===========================================================================+# File: bytebase-sql-review.sh+# Description: usage: ./bytebase-sql-review.sh --pull-request-id=[pr id] --repo-id=[repo id] --repo-url=[repo URL] --api=[API URL] --token=[API token]+# ===========================================================================++# Get parameters+for i in "$@"+do+case $i in+ --pull-request-id=*)+ PR_ID="${i#*=}"+ shift+ ;;+ --repo-id=*)+ REPO_ID="${i#*=}"+ shift+ ;;+ --repo-url=*)+ REPO_URL="${i#*=}"+ shift+ ;;+ --token=*)+ API_TOKEN="${i#*=}"+ shift+ ;;+ --api=*)+ API_URL="${i#*=}"+ shift+ ;;+ *) # unknown option+ ;;+esac+done++echo "Start request $API_URL"++if [[ $PR_ID == "" ]]; then exit 0; fi++request_body=$(jq -n \+--arg 'repositoryId' "$REPO_ID" \+--arg 'pullRequestId' "$PR_ID" \+--arg 'webURL' "$REPO_URL" \+'$ARGS.named')++response=$(curl -s --show-error -X POST $API_URL \+-H "X-SQL-Review-Token: $API_TOKEN" \+-H "Content-Type: application/json" \+-d "$request_body")++echo "response: $response"++content=$(echo "$response" | jq -r '.content')+len=$(echo "$content" | jq '. | length')+if [[ $len == 0 ]]; then exit 0; fi++msg=$(echo "$content" | jq -r '.[0]')+echo $msg >> test-results/bytebase-sql-review.xmldiff --git a/backend/plugin/vcs/bitbucket/pipeline-step.yml b/backend/plugin/vcs/bitbucket/pipeline-step.ymlnew file mode 100644index 0000000000..076597db54--- /dev/null+++ b/backend/plugin/vcs/bitbucket/pipeline-step.yml@@ -0,0 +1,4 @@+name: %s+image: atlassian/default-image:4+script:+ - bash %s --pull-request-id="$BITBUCKET_PR_ID" --repo-id="$BITBUCKET_REPO_UUID" --repo-url="$BITBUCKET_GIT_HTTP_ORIGIN" --api="%s" --token="%s"diff --git a/backend/plugin/vcs/bitbucket/sql_review.go b/backend/plugin/vcs/bitbucket/sql_review.gonew file mode 100644index 0000000000..8625e4adcc--- /dev/null+++ b/backend/plugin/vcs/bitbucket/sql_review.go@@ -0,0 +1,109 @@+package bitbucket++import (+ _ "embed"+ "fmt"++ "github.com/pkg/errors"++ "gopkg.in/yaml.v3"+)++type pipelineStep struct {+ Name string `yaml:"name"`+ Image string `yaml:"image"`+ Script []string `yaml:"script"`+}++type pipeline struct {+ Step *pipelineStep `yaml:"step"`+}++const (+ // CIFilePath is the local path for BitBucket ci file.+ CIFilePath = "bitbucket-pipelines.yml"+ // SQLReviewScriptFilePath is the local path for SQL review CI script.+ SQLReviewScriptFilePath = ".pipeline/bytebase-sql-review.sh"+ pipelineStepName = "Bytebase SQL Review"+)++// sqlReviewPipelineStep is the pipeline step for SQL review in VCS workflow.+//+//go:embed pipeline-step.yml+var sqlReviewPipelineStep string++// SQLReviewScript is the script file for SQL review in VCS workflow.+//+//go:embed bytebase-sql-review.sh+var SQLReviewScript string++func getSQLReviewStep(endpoint, webhookSecret string) string {+ return fmt.Sprintf(+ sqlReviewPipelineStep,+ pipelineStepName,+ SQLReviewScriptFilePath,+ endpoint,+ // TODO(ed): insert secret in the repo environment variable and use vcs.SQLReviewAPISecretName.+ webhookSecret,+ )+}++func SetupBitBucketCI(bitBucketCI map[string]any, endpoint, webhookSecret string) (string, error) {+ if _, ok := bitBucketCI["image"]; !ok {+ bitBucketCI["image"] = "atlassian/default-image:4"+ }+ if _, ok := bitBucketCI["pipelines"]; !ok {+ bitBucketCI["pipelines"] = make(map[string]any)+ }+ if _, ok := bitBucketCI["pipelines"].(map[string]any)["pull-requests"]; !ok {+ bitBucketCI["pipelines"].(map[string]any)["pull-requests"] = make(map[string]any)+ }+ if _, ok := bitBucketCI["pipelines"].(map[string]any)["pull-requests"].(map[string]any)["**"]; !ok {+ bitBucketCI["pipelines"].(map[string]any)["pull-requests"].(map[string]any)["**"] = []any{}+ }++ var prSteps []any+ switch steps := bitBucketCI["pipelines"].(map[string]any)["pull-requests"].(map[string]any)["**"].(type) {+ case []any:+ prSteps = append(prSteps, steps...)+ default:+ prSteps = append(prSteps, steps)+ }++ stepStr := getSQLReviewStep(endpoint, webhookSecret)+ pipelineStep := &pipelineStep{}+ if err := yaml.Unmarshal([]byte(stepStr), pipelineStep); err != nil {+ return "", errors.Wrapf(err, "failed to parse pipeline step")+ }++ index := findSQLReviewStepIndex(prSteps)+ if index >= 0 {+ prSteps = append(prSteps[:index], prSteps[index+1:]...)+ }+ prSteps = append(prSteps, &pipeline{+ Step: pipelineStep,+ })++ bitBucketCI["pipelines"].(map[string]any)["pull-requests"].(map[string]any)["**"] = prSteps++ newContent, err := yaml.Marshal(bitBucketCI)+ if err != nil {+ return "", err+ }++ return string(newContent), nil+}++func findSQLReviewStepIndex(steps []any) int {+ for i, data := range steps {+ if val, ok := data.(map[string]any); ok {+ if step, ok := val["step"].(map[string]any); ok {+ if step["name"] == pipelineStepName {+ return i+ }+ }+ }+ }++ return -1+}diff --git a/backend/plugin/vcs/gitlab/sql_review.go b/backend/plugin/vcs/gitlab/sql_review.goindex 1ee104a660..9a70b98265 100644--- a/backend/plugin/vcs/gitlab/sql_review.go+++ b/backend/plugin/vcs/gitlab/sql_review.go@@ -43,7 +43,7 @@ func SetupGitLabCI(gitlabCI map[string]any) (string, error) {includeList = append(includeList, include)}- if _, ok := findSQLReviewCI(includeList); !ok {+ if !existSQLReviewCI(includeList) {includeList = append(includeList, map[string]string{sqlReviewCIFileRelativePathKeywordInGitLabCI: SQLReviewCIFilePath})}@@ -56,14 +56,14 @@ func SetupGitLabCI(gitlabCI map[string]any) (string, error) {return string(newContent), nil}-func findSQLReviewCI(include []any) (map[string]any, bool) {+func existSQLReviewCI(include []any) bool {for _, data := range include {if val, ok := data.(map[string]any); ok {if val[sqlReviewCIFileRelativePathKeywordInGitLabCI] == SQLReviewCIFilePath {- return val, true+ return true}}}- return nil, false+ return false}diff --git a/backend/plugin/vcs/gitlab/sql_review_test.go b/backend/plugin/vcs/gitlab/sql_review_test.goindex 40230e646f..d929e1a213 100644--- a/backend/plugin/vcs/gitlab/sql_review_test.go+++ b/backend/plugin/vcs/gitlab/sql_review_test.go@@ -40,7 +40,6 @@ func Test_SetupGitLabCI(t *testing.T) {include, ok := content["include"].([]any)assert.Equal(t, ok, true)- sqlReviewCI, ok := findSQLReviewCI(include)- assert.Equal(t, ok, true)- assert.NotNil(t, sqlReviewCI)+ sqlReviewCI := existSQLReviewCI(include)+ assert.Equal(t, sqlReviewCI, true)}diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vueindex 97e1e87908..c19c7a6cf5 100644--- a/frontend/src/components/RepositoryForm.vue+++ b/frontend/src/components/RepositoryForm.vue@@ -326,7 +326,7 @@ import {schemaChangeToJSON,} from "@/types/proto/v1/project_service";import { PlanType } from "@/types/proto/v1/subscription_service";-import { hasWorkspacePermissionV2 } from "@/utils";+import { hasWorkspacePermissionV2, supportSQLReviewCI } from "@/utils";const FILE_REQUIRED_PLACEHOLDER = "{{DB_NAME}}, {{VERSION}}, {{TYPE}}";const SCHEMA_REQUIRED_PLACEHOLDER = "{{DB_NAME}}";@@ -397,11 +397,7 @@ const isProjectSchemaChangeTypeSDL = computed(() => {return (props.schemaChangeType || SchemaChange.DDL) === SchemaChange.SDL;});const canEnableSQLReview = computed(() => {- return (- props.vcsType == ExternalVersionControl_Type.GITHUB ||- props.vcsType === ExternalVersionControl_Type.GITLAB ||- props.vcsType === ExternalVersionControl_Type.AZURE_DEVOPS- );+ return supportSQLReviewCI(props.vcsType);});const enableSQLReviewTitle = computed(() => {switch (props.vcsType) {@@ -412,7 +408,7 @@ const enableSQLReviewTitle = computed(() => {case ExternalVersionControl_Type.AZURE_DEVOPS:return t("repository.sql-review-ci-enable-azure");default:- return "";+ return t("repository.sql-review-ci-enable-title");}});diff --git a/frontend/src/components/RepositoryPanel.vue b/frontend/src/components/RepositoryPanel.vueindex 46bf4758ca..e78d8856cd 100644--- a/frontend/src/components/RepositoryPanel.vue+++ b/frontend/src/components/RepositoryPanel.vue@@ -152,7 +152,7 @@</div></BBModal><BBAlert- v-if="supportSQLReviewCI"+ v-if="supportSQLReview"v-model:show="state.showSetupSQLReviewCIFailureModal"type="warning":ok-text="$t('common.retry')"@@ -170,7 +170,7 @@"/><BBModal- v-if="supportSQLReviewCI && state.showLoadingSQLReviewPRModal"+ v-if="supportSQLReview && state.showLoadingSQLReviewPRModal"class="relative overflow-hidden":show-close="false":close-on-esc="false"@@ -191,7 +191,7 @@</div></BBModal><BBModal- v-if="supportSQLReviewCI && state.showRestoreSQLReviewCIModal"+ v-if="supportSQLReview && state.showRestoreSQLReviewCIModal"class="relative overflow-hidden":title="$t('repository.sql-review-ci-remove')"@close="onSQLReviewCIModalClose"@@ -277,6 +277,7 @@ import {ExternalVersionControl_Type,} from "@/types/proto/v1/externalvs_service";import { Project, SchemaChange } from "@/types/proto/v1/project_service";+import { supportSQLReviewCI } from "@/utils";import { ExternalRepositoryInfo, RepositoryConfig } from "../types";interface LocalState {@@ -381,13 +382,9 @@ const isProjectSchemaChangeTypeSDL = computed(() => {return state.schemaChangeType === SchemaChange.SDL;});-const supportSQLReviewCI = computed(() => {+const supportSQLReview = computed(() => {const { type } = props.vcs;- return (- type == ExternalVersionControl_Type.GITHUB ||- type === ExternalVersionControl_Type.GITLAB ||- type === ExternalVersionControl_Type.AZURE_DEVOPS- );+ return supportSQLReviewCI(type);});const allowUpdate = computed(() => {diff --git a/frontend/src/components/VCS/VCSProviderOAuthPanel.vue b/frontend/src/components/VCS/VCSProviderOAuthPanel.vueindex 5db120f5a4..d1634d1192 100644--- a/frontend/src/components/VCS/VCSProviderOAuthPanel.vue+++ b/frontend/src/components/VCS/VCSProviderOAuthPanel.vue@@ -411,7 +411,7 @@</dt><dd class="text-sm text-main">Account > Read, Webhooks > Read and write, Repositories >- Write+ Write, Pipelines > Edit variables, Pull requests > Write</dd></div></dl>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 864a4187da..eeffb607ec 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1770,6 +1770,7 @@"sql-review-ci-enable-gitlab": "Enable SQL Review CI via GitLab CI","sql-review-ci-enable-github": "Enable SQL Review CI via GitHub Action","sql-review-ci-enable-azure": "Enable SQL Review CI via Azure DevOps Pipeline",+ "sql-review-ci-enable-title": "Enable SQL Review CI via pipeline","sql-review-ci-description": "Bytebase will create a {pr} to set up the SQL review CI in your repository. In every {pr}, environment-based SQL review policy will check against changed files matching the \"{pathTemplate}\".","sql-review-ci-setup": "Setup SQL Review CI","sql-review-ci-setup-failed": "Failed to setup SQL Review CI",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 3a02ad3ec3..64b17dc7cd 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1768,6 +1768,7 @@"sql-review-ci-enable-gitlab": "Habilitar la revisión de SQL CI a través de GitLab CI","sql-review-ci-enable-github": "Habilitar la revisión de SQL CI a través de la acción de GitHub","sql-review-ci-enable-azure": "Habilite SQL Review CI a través de Azure DevOps Pipeline",+ "sql-review-ci-enable-title": "Habilite SQL Review CI a través de canalización","sql-review-ci-description": "Bytebase creará un {pr} para configurar la revisión de SQL CI en su repositorio. En cada {pr}, la política de revisión de SQL basada en el entorno verificará los archivos modificados que coincidan con el \"{pathTemplate}\".","sql-review-ci-setup": "Configurar revisión de SQL CI","sql-review-ci-setup-failed": "Error al configurar la revisión de SQL CI",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 2e5e494f62..d5dd2e235d 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1769,6 +1769,7 @@"sql-review-ci-enable-gitlab": "GitLab CIを介してSQLレビューCIを有効にする","sql-review-ci-enable-github": "GitHubアクションを介してSQLレビューCIを有効にする","sql-review-ci-enable-azure": "Azure DevOpsパイプラインを介してSQLレビューCIを有効にする",+ "sql-review-ci-enable-title": "パイプライン経由で SQL Review CI を有効にする","sql-review-ci-description": "Bytebaseはリポジトリ内でSQLレビューCIを設定するための{pr}を作成します。各{pr}では、環境ベースのSQLレビューポリシーが\"{pathTemplate}\"に一致する変更されたファイルに対してチェックを行います。","sql-review-ci-setup": "SQLレビューCIの設定","sql-review-ci-setup-failed": "SQLレビューCIの設定に失敗しました",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex ecd7d83333..caf4697967 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1770,6 +1770,7 @@"sql-review-ci-enable-gitlab": "Kích hoạt CI đánh giá SQL thông qua GitLab CI","sql-review-ci-enable-github": "Kích hoạt CI đánh giá SQL thông qua hành động GitHub","sql-review-ci-enable-azure": "Kích hoạt CI đánh giá SQL thông qua Azure DevOps Pipeline",+ "sql-review-ci-enable-title": "Bật CI đánh giá SQL qua đường dẫn","sql-review-ci-description": "Bytebase sẽ tạo một {pr} để thiết lập CI đánh giá SQL trong kho lưu trữ của bạn. Trong mọi {pr}, chính sách đánh giá SQL dựa trên môi trường sẽ kiểm tra các tệp đã thay đổi khớp với \"{pathTemplate}\".","sql-review-ci-setup": "Thiết lập CI đánh giá SQL","sql-review-ci-setup-failed": "Không thể thiết lập CI đánh giá SQL",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex ffe15fbf3b..6a2d73a91d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1766,7 +1766,8 @@"sql-review-ci-enable-gitlab": "基于 GitLab CI 开启 SQL 审核","sql-review-ci-enable-github": "基于 GitHub Action 开启 SQL 审核","sql-review-ci-enable-azure": "基于 Azure DevOps Pipeline 开启 SQL 审核",- "sql-review-ci-description": "Bytebase 会发起 {pr} 为您的代码仓库配置 SQL 审核 CI。在每一个 {pr} 中,任何匹配上「{pathTemplate}」的文件修改将被赋予对应环境的 SQL 审核策略。",+ "sql-review-ci-enable-title": "基于 pipeline 开启 SQL 审核",+ "sql-review-ci-description": "Bytebase 会发起{pr}为您的代码仓库配置 SQL 审核 CI。在每一个{pr}中,任何匹配上「{pathTemplate}」的文件修改将被赋予对应环境的 SQL 审核策略。","sql-review-ci-setup": "配置 SQL 审核 CI","sql-review-ci-setup-failed": "SQL 审核 CI 创建失败","sql-review-ci-setup-pr": "查看{pr}",diff --git a/frontend/src/utils/v1/vcs.ts b/frontend/src/utils/v1/vcs.tsindex 4c188d7d64..15b7755a21 100644--- a/frontend/src/utils/v1/vcs.ts+++ b/frontend/src/utils/v1/vcs.ts@@ -3,6 +3,7 @@ import {ExternalVersionControl,ExternalVersionControl_Type,} from "@/types/proto/v1/externalvs_service";+import { isDev } from "@/utils";export const getVCSUIType = (vcs: ExternalVersionControl): VCSUIType => {switch (vcs.type) {@@ -21,3 +22,14 @@ export const getVCSUIType = (vcs: ExternalVersionControl): VCSUIType => {return "GITLAB_SELF_HOST";}};++export const supportSQLReviewCI = (+ vcsType: ExternalVersionControl_Type+): boolean => {+ return (+ vcsType === ExternalVersionControl_Type.GITHUB ||+ vcsType === ExternalVersionControl_Type.GITLAB ||+ vcsType === ExternalVersionControl_Type.AZURE_DEVOPS ||+ (vcsType === ExternalVersionControl_Type.BITBUCKET && isDev())+ );+};