Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sonar options #1172

Merged
merged 2 commits into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions help/sonarcube.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ compilation has finished. Then the result is collected and send to the SonarQube
{p with
Key = "MyProject"
Name = "Main solution"
Version = "1.0.0" })
Version = "1.0.0" }
)

Target "EndSonarQube" (fun _ ->
SonarQube End (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
Version = "1.0.0" })
Version = "1.0.0" }
)

Target "Default" DoNothing
Expand All @@ -45,3 +45,28 @@ compilation has finished. Then the result is collected and send to the SonarQube
RunTargetOrDefault "Default"

The MSBuild runner is searched in 'tools/SonarQube'. This can be overwritten with the ToolsPath property of the parameters.

## Additional options for SonarQube

* You can send additional global settings to the server with the '/d:' parameter.
In the SonarQubeParams, this is the new field Settings:

SonarQube Begin (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
Version = "1.0.0"
Settings = ["sonar.debug"; "sonar.newversion"] }
)

* Configuration can also be read from a configuration file. This is the '/s:' parameter.
This can be done with the new field Config:

SonarQube Begin (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
Version = "1.0.0"
Config = Some("myconfig.cfg") }
)

23 changes: 20 additions & 3 deletions src/app/FakeLib/SonarQubeHelper.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Contains a task to run the msbuild runner of [Sonar Qube analyzer](http://sonarqube.org).
module Fake.SonarQubeHelper
open TraceHelper

/// The supported commands of Sonar Qube. It is called with Begin before compilation, and End after compilation.
type SonarQubeCall = Begin | End
Expand All @@ -14,21 +15,37 @@ type SonarQubeParams =
Name : string
/// Version number of the project
Version : string
/// Individual global settings for SonarQube
Settings : List<string>
/// Read settings from configuration file
Config : string option
}

/// SonarQube default parameters - tries to locate MSBuild.SonarQube.exe in any subfolder.
let SonarQubeDefaults =
{ ToolsPath = findToolInSubPath "MSBuild.SonarQube.Runner.exe" (currentDirectory @@ "tools" @@ "SonarQube")
Key = null
Name = null
Version = "1.0" }
Version = "1.0"
Settings = []
Config = None }

/// Execute the external msbuild runner of Sonar Qube. Parameters are fiven to the command line tool as required.
let SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
let sonarPath = parameters.ToolsPath
let args = match call with
| Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\""
let setArgs = parameters.Settings |> List.fold (fun acc x -> acc + "/d:"+x+" ") ""
//match parameters.Settings with
//| Some(x) -> (" /d:"+x)
//| None -> ""
let cfgArgs =
match parameters.Config with
| Some(x) -> (" /s:"+x)
| None -> ""
let args =
match call with
| Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\" " + setArgs + cfgArgs
| End -> "end"

let result =
ExecProcess (fun info ->
info.FileName <- sonarPath
Expand Down