Skip to content

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

chore(action): azure devops (#15802)

boojack2bb879d9c966
diff --git a/action/azure_devops.go b/action/azure_devops.go
new file mode 100644
index 0000000000..f9bd635c3b
--- /dev/null
+++ b/action/azure_devops.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "fmt"
+
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
+)
+
+func loggingReleaseChecks(resp *v1pb.CheckReleaseResponse) error {
+ if resp == nil || len(resp.Results) == 0 {
+ fmt.Println("No check results found.")
+ return nil
+ }
+
+ hasError := false
+ hasWarning := false
+ for _, result := range resp.Results {
+ var advices []string
+ for _, advice := range result.Advices {
+ if advice.Status == v1pb.Advice_WARNING || advice.Status == v1pb.Advice_ERROR {
+ advices = append(advices, advice.Content)
+ }
+ }
+
+ if len(advices) > 0 {
+ fmt.Printf("%s with %s has %d advices\n", result.File, result.Target, len(advices))
+ for _, advice := range result.Advices {
+ if advice.Status == v1pb.Advice_WARNING {
+ hasWarning = true
+ } else if advice.Status == v1pb.Advice_ERROR {
+ hasError = true
+ }
+ fmt.Printf("* (%s) %d - %s: %s\n", advice.Status.String(), advice.Code, advice.Title, advice.Content)
+ }
+ }
+ }
+
+ if hasError {
+ // Azure Pipelines log command.
+ fmt.Println("##vso[task.logissue type=error;]SQL review failed with errors")
+ } else if hasWarning {
+ fmt.Println("##vso[task.logissue type=warning;]SQL review has warnings")
+ }
+
+ if hasError {
+ return fmt.Errorf("SQL review failed with errors")
+ }
+ return nil
+}
diff --git a/action/main.go b/action/main.go
index f282c8771f..4eda24dcca 100644
--- a/action/main.go
+++ b/action/main.go
@@ -53,6 +53,10 @@ func run(platform JobPlatform) error {
if err := writeReleaseCheckToCodeQualityJSON(checkReleaseResponse); err != nil {
return err
}
+ } else if platform == AzureDevOps {
+ if err := loggingReleaseChecks(checkReleaseResponse); err != nil {
+ return err
+ }
}
return nil
}