Adds setting for branch analysis
This commit is contained in:
parent
6c61395706
commit
d0fc9a1d7f
1
DOCS.md
1
DOCS.md
@ -60,6 +60,7 @@ Safety first, the host and token are stored in Drone Secrets.
|
|||||||
* DEBUG: Display INFO logs + more details at DEBUG level.
|
* DEBUG: Display INFO logs + more details at DEBUG level.
|
||||||
* TRACE: Display DEBUG logs + the timings of all ElasticSearch queries and Web API calls executed by the SonarQube Scanner.
|
* TRACE: Display DEBUG logs + the timings of all ElasticSearch queries and Web API calls executed by the SonarQube Scanner.
|
||||||
* `showProfiling`: Display logs to see where the analyzer spends time. Default value `false`
|
* `showProfiling`: Display logs to see where the analyzer spends time. Default value `false`
|
||||||
|
* `branchAnalysis`: Pass currently analysed branch to SonarQube. (Must not be active for initial scan!) Default value `false`
|
||||||
|
|
||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
|
BIN
drone-sonar
BIN
drone-sonar
Binary file not shown.
6
main.go
6
main.go
@ -82,6 +82,11 @@ func main() {
|
|||||||
Value: "false",
|
Value: "false",
|
||||||
EnvVar: "PLUGIN_SHOWPROFILING",
|
EnvVar: "PLUGIN_SHOWPROFILING",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "branchAnalysis",
|
||||||
|
Usage: "execute branchAnalysis",
|
||||||
|
EnvVar: "PLUGIN_BRANCHANALYSIS",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
@ -103,6 +108,7 @@ func run(c *cli.Context) {
|
|||||||
Exclusions: c.String("exclusions"),
|
Exclusions: c.String("exclusions"),
|
||||||
Level: c.String("level"),
|
Level: c.String("level"),
|
||||||
showProfiling: c.String("showProfiling"),
|
showProfiling: c.String("showProfiling"),
|
||||||
|
branchAnalysis: c.Bool("branchAnalysis"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ type (
|
|||||||
Exclusions string
|
Exclusions string
|
||||||
Level string
|
Level string
|
||||||
showProfiling string
|
showProfiling string
|
||||||
|
branchAnalysis bool
|
||||||
}
|
}
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
Config Config
|
Config Config
|
||||||
@ -35,7 +36,6 @@ 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,
|
||||||
@ -44,6 +44,11 @@ func (p Plugin) Exec() error {
|
|||||||
"-Dsonar.showProfiling=" + p.Config.showProfiling,
|
"-Dsonar.showProfiling=" + p.Config.showProfiling,
|
||||||
"-Dsonar.scm.provider=git",
|
"-Dsonar.scm.provider=git",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Config.branchAnalysis {
|
||||||
|
args = append(args, "-Dsonar.branch.name="+p.Config.Branch)
|
||||||
|
}
|
||||||
|
|
||||||
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, " "))
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
|
Loading…
Reference in New Issue
Block a user