Skip to content

Commit 1f5644c

Browse files
Merge pull request #78 from diegopereiraeng/main
Quality Gate Type Check Param for selection
2 parents 3bdb843 + 225e1c9 commit 1f5644c

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

.drone.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ steps:
1919
when:
2020
ref:
2121
- "refs/pull/**" # Only run for pull requests
22-
- name: publish-2.1.0
22+
- name: publish-2.1.1
2323
image: plugins/docker:20
2424
settings:
2525
# auto_tag: true
2626
# auto_tag_suffix: v2.0.2-java17
2727
tags:
28-
- v2.1.0
29-
- latest
28+
- v2.1.1
29+
# - latest
3030
# - stable-java17
3131
daemon_off: false
3232
dockerfile: Dockerfile

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ func main() {
108108
Value: "true",
109109
EnvVar: "PLUGIN_SONAR_QUALITY_ENABLED",
110110
},
111+
cli.StringFlag{
112+
Name: "quality_gate_type",
113+
Usage: "if this setting is not set the default is analysisID, if you want to use other QG checks then choose: branch, pullRequest or projectKey",
114+
Value: "analysisID",
115+
EnvVar: "PLUGIN_QG_TYPE",
116+
},
111117
cli.StringFlag{
112118
Name: "qualitygate_timeout",
113119
Usage: "number in seconds for timeout",

plugin.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,36 @@ func staticScan(p *Plugin) (*SonarReport, error) {
658658
}
659659

660660
func getStatus(task *TaskResponse, report *SonarReport) string {
661-
reportRequest := url.Values{
662-
"analysisId": {task.Task.AnalysisID},
661+
662+
qg_type := os.Getenv("PLUGIN_QG_TYPE")
663+
664+
var reportRequest url.Values
665+
666+
if qg_type == "branch" {
667+
qg_branch := os.Getenv("PLUGIN_BRANCH")
668+
reportRequest = url.Values{
669+
"branch": {qg_branch},
670+
}
671+
} else if qg_type == "pullRequest" {
672+
qg_pr := os.Getenv("PLUGIN_PR_KEY")
673+
reportRequest = url.Values{
674+
"pullRequest": {qg_pr},
675+
}
676+
677+
} else if qg_type == "projectKey" {
678+
qg_projectKey := os.Getenv("PLUGIN_SONAR_KEY")
679+
reportRequest = url.Values{
680+
"projectKey": {qg_projectKey},
681+
}
682+
} else {
683+
reportRequest = url.Values{
684+
"analysisId": {task.Task.AnalysisID},
685+
}
663686
}
687+
688+
// reportRequest := url.Values{
689+
// "analysisId": {task.Task.AnalysisID},
690+
// }
664691
sonarToken := os.Getenv("PLUGIN_SONAR_TOKEN")
665692

666693
// First try with Basic Auth

sonar-scanner-plugin

-8.97 MB
Binary file not shown.

0 commit comments

Comments
 (0)