Skip to content

Commit 0da2a7c

Browse files
Merge pull request #80 from diegopereiraeng/main
Sonar badge
2 parents 74a1da5 + 192b46a commit 0da2a7c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Quality Gate Status](https://sonar.harness-demo.site/api/project_badges/measure?project=sonarqube-scanner&metric=alert_status&token=sqb_44744288d1f30ee517e04dbf69e29f836cc8f45b)](https://sonar.harness-demo.site/dashboard?id=sonarqube-scanner)
2+
13
# Harness Drone/CIE SonarQube Plugin with Quality Gate
24

35
This plugin is designed to run SonarQube scans and handle the results and convert it to JUnit Format. It's written in Go and check the report results for status OK.

plugin.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ func getStatus(task *TaskResponse, report *SonarReport) string {
750750

751751
fmt.Printf("%+v", projectReport)
752752
fmt.Printf("\n")
753-
result := ParseJunit(projectReport, "BankingApp")
753+
result := ParseJunit(projectReport, qg_projectKey)
754754
file, _ := xml.MarshalIndent(result, "", " ")
755755
_ = ioutil.WriteFile("sonarResults.xml", file, 0644)
756756

@@ -810,12 +810,13 @@ func getStatusID(taskIDOld string, sonarHost string, projectSlug string) (string
810810
if err != nil {
811811
panic(err)
812812
}
813+
qg_projectKey := os.Getenv("PLUGIN_SONAR_KEY")
813814

814815
fmt.Printf("%+v", projectReport)
815816
fmt.Printf("\n")
816-
result := ParseJunit(projectReport, "BankingApp")
817+
result := ParseJunit(projectReport, qg_projectKey)
817818
file, _ := xml.MarshalIndent(result, "", " ")
818-
_ = ioutil.WriteFile("sonarResults.xml", file, 0644)
819+
_ = os.WriteFile("sonarResults.xml", file, 0644)
819820

820821
fmt.Printf("\n")
821822
fmt.Printf("\n======> JUNIT Exporter <======\n")
@@ -884,12 +885,13 @@ func getStatusV2(scanType string, scanValue string, sonarHost string, projectSlu
884885
if err != nil {
885886
panic(err)
886887
}
888+
qg_projectKey := os.Getenv("PLUGIN_SONAR_KEY")
887889

888890
fmt.Printf("%+v", projectReport)
889891
fmt.Printf("\n")
890-
result := ParseJunit(projectReport, "BankingApp")
892+
result := ParseJunit(projectReport, qg_projectKey)
891893
file, _ := xml.MarshalIndent(result, "", " ")
892-
_ = ioutil.WriteFile("sonarResults.xml", file, 0644)
894+
_ = os.WriteFile("sonarResults.xml", file, 0644)
893895

894896
fmt.Printf("\n")
895897
fmt.Printf("\n======> JUNIT Exporter <======\n")

0 commit comments

Comments
 (0)