Pass branch name to Sonar
This commit is contained in:
parent
d2afbb890a
commit
6c61395706
BIN
drone-sonar
BIN
drone-sonar
Binary file not shown.
6
main.go
6
main.go
@ -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"),
|
||||||
|
27
plugin.go
27
plugin.go
@ -1,25 +1,26 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Config struct {
|
Config struct {
|
||||||
Key string
|
Key string
|
||||||
Name string
|
Name string
|
||||||
Host string
|
Host string
|
||||||
Token string
|
Token string
|
||||||
|
|
||||||
Version string
|
Version string
|
||||||
Sources string
|
Branch string
|
||||||
Timeout string
|
Sources string
|
||||||
Inclusions string
|
Timeout string
|
||||||
Exclusions string
|
Inclusions string
|
||||||
Level string
|
Exclusions string
|
||||||
showProfiling string
|
Level string
|
||||||
|
showProfiling string
|
||||||
}
|
}
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
Config Config
|
Config Config
|
||||||
@ -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, " "))
|
||||||
|
Loading…
Reference in New Issue
Block a user