Pass branch name to Sonar

This commit is contained in:
Mario Lubenka 2019-11-20 21:06:19 +01:00
parent d2afbb890a
commit 6c61395706
3 changed files with 20 additions and 13 deletions

Binary file not shown.

View File

@ -43,6 +43,11 @@ func main() {
Usage: "Project version",
EnvVar: "DRONE_BUILD_NUMBER",
},
cli.StringFlag{
Name: "branch",
Usage: "Project branch",
EnvVar: "DRONE_BRANCH",
},
cli.StringFlag{
Name: "timeout",
Usage: "Web request timeout",
@ -91,6 +96,7 @@ func run(c *cli.Context) {
Token: c.String("token"),
Version: c.String("ver"),
Branch: c.String("branch"),
Timeout: c.String("timeout"),
Sources: c.String("sources"),
Inclusions: c.String("inclusions"),

View File

@ -1,9 +1,9 @@
package main
import (
"strings"
"fmt"
"os/exec"
"strings"
)
type (
@ -14,6 +14,7 @@ type (
Token string
Version string
Branch string
Sources string
Timeout string
Inclusions string
@ -34,6 +35,7 @@ func (p Plugin) Exec() error {
"-Dsonar.login=" + p.Config.Token,
"-Dsonar.projectVersion=" + p.Config.Version,
"-Dsonar.branch.name=" + p.Config.Branch,
"-Dsonar.sources=" + p.Config.Sources,
"-Dsonar.ws.timeout=" + p.Config.Timeout,
"-Dsonar.inclusions=" + p.Config.Inclusions,
@ -41,7 +43,6 @@ func (p Plugin) Exec() error {
"-Dsonar.log.level=" + p.Config.Level,
"-Dsonar.showProfiling=" + p.Config.showProfiling,
"-Dsonar.scm.provider=git",
}
cmd := exec.Command("sonar-scanner", args...)
// fmt.Printf("==> Executing: %s\n", strings.Join(cmd.Args, " "))