Browse Source

Pass branch name to Sonar

master
Mario Lubenka 2 years ago
parent
commit
6c61395706
3 changed files with 20 additions and 13 deletions
  1. BIN
      drone-sonar
  2. +6
    -0
      main.go
  3. +14
    -13
      plugin.go

BIN
drone-sonar View File


+ 6
- 0
main.go 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"),


+ 14
- 13
plugin.go View File

@ -1,25 +1,26 @@
package main
import (
"strings"
"fmt"
"os/exec"
"strings"
)
type (
Config struct {
Key string
Name string
Host string
Token string
Key string
Name string
Host string
Token string
Version string
Sources string
Timeout string
Inclusions string
Exclusions string
Level string
showProfiling string
Version string
Branch string
Sources string
Timeout string
Inclusions string
Exclusions string
Level string
showProfiling string
}
Plugin struct {
Config Config
@ -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, " "))


Loading…
Cancel
Save