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

View File

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