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

Added Organization field for SonarQube tester #2358

Merged
merged 3 commits into from
Aug 25, 2019
Merged
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
47 changes: 39 additions & 8 deletions src/app/Fake.Testing.SonarQube/SonarQube.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Fake.Testing.SonarQube
type SonarQubeParams = {
/// FileName of the SonarQube runner exe.
ToolsPath : string
/// Organization which owns the SonarQube project
Organization : string option
/// Key to identify the SonarQube project
Key : string
/// Name of the project
Expand All @@ -29,6 +31,7 @@ module Fake.Testing.SonarQube
/// SonarQube default parameters - tries to locate MSBuild.SonarQube.exe in any subfolder.
let SonarQubeDefaults =
{ ToolsPath = Tools.findToolInSubPath "MSBuild.SonarQube.Runner.exe" (Directory.GetCurrentDirectory() @@ "tools" @@ "SonarQube")
Organization = None
Key = null
Name = null
Version = "1.0"
Expand All @@ -39,18 +42,46 @@ module Fake.Testing.SonarQube
/// Execute the external msbuild runner of SonarQube. Parameters are given to the command line tool as required.
let private SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
let sonarPath = parameters.ToolsPath
let setArgs = parameters.Settings |> List.fold (fun acc x -> acc + "/d:" + x + " ") ""

let cfgArgs =
let arg flag param =
let augmentedParam = @""+ param + @""
(sprintf "/%s:%s" flag augmentedParam).Trim()

let organisationArgument =
match parameters.Organization with
| None -> None
| Some (organization) -> Some (arg "o" organization)

let configurationArgument =
match parameters.Config with
| Some(x) -> (" /s:"+x)
| None -> ""
| None -> None
| Some x -> Some ( arg "s" x )

let beginInitialArguments =
Arguments.Empty
|> Arguments.appendIf true "begin"
|> Arguments.appendIf true (arg "k" parameters.Key)
|> Arguments.appendIf true (arg "n" parameters.Name)
|> Arguments.appendIf true (arg "v" parameters.Version)
|> Arguments.appendIf (organisationArgument.IsNone = false) organisationArgument.Value
|> Arguments.appendIf (configurationArgument.IsNone = false) configurationArgument.Value

let beginCall =
parameters.Settings
|> List.fold (fun arguments x -> arguments |> Arguments.appendIf true (sprintf "/d:%s" x) ) beginInitialArguments

let endInitialArguments =
Arguments.Empty
|> Arguments.appendIf true "end"
|> Arguments.appendIf (configurationArgument.IsNone = false) configurationArgument.Value

let endCall =
parameters.Settings
|> List.fold (fun arguments x -> arguments |> Arguments.appendIf true (sprintf "/d:%s" x) ) endInitialArguments

let args =
match call with
| Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\" " + setArgs + cfgArgs
| End -> "end " + setArgs + cfgArgs

| Begin -> beginCall.ToStartInfo
| End -> endCall.ToStartInfo
let result =
Process.execSimple ((fun info ->
{ info with
Expand Down