From 81bd478a55d67355193e1f27b0ae2a8aca5a23cf Mon Sep 17 00:00:00 2001 From: Lutando Ngqakaza Date: Wed, 17 Jul 2019 11:04:12 +0200 Subject: [PATCH 1/2] added Organization field to SonarQubeParams --- src/app/Fake.Testing.SonarQube/SonarQube.fs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/Fake.Testing.SonarQube/SonarQube.fs b/src/app/Fake.Testing.SonarQube/SonarQube.fs index feaf07f7b9f..4435466677d 100644 --- a/src/app/Fake.Testing.SonarQube/SonarQube.fs +++ b/src/app/Fake.Testing.SonarQube/SonarQube.fs @@ -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 @@ -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" @@ -40,6 +43,10 @@ module Fake.Testing.SonarQube let private SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) = let sonarPath = parameters.ToolsPath let setArgs = parameters.Settings |> List.fold (fun acc x -> acc + "/d:" + x + " ") "" + let orgArgs = + match parameters.Organization with + | Some (organization) -> (" /o:" + organization) + | None -> "" let cfgArgs = match parameters.Config with @@ -48,7 +55,7 @@ module Fake.Testing.SonarQube let args = match call with - | Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\" " + setArgs + cfgArgs + | Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\" " + setArgs + cfgArgs + orgArgs | End -> "end " + setArgs + cfgArgs let result = From 3cd8ddc7d0e72b65e076ebd40bf410bc5c7138eb Mon Sep 17 00:00:00 2001 From: Lutando Ngqakaza Date: Wed, 7 Aug 2019 16:08:16 +0200 Subject: [PATCH 2/2] still a work in progress --- src/app/Fake.Testing.SonarQube/SonarQube.fs | 46 ++++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/app/Fake.Testing.SonarQube/SonarQube.fs b/src/app/Fake.Testing.SonarQube/SonarQube.fs index 4435466677d..832af0fcf61 100644 --- a/src/app/Fake.Testing.SonarQube/SonarQube.fs +++ b/src/app/Fake.Testing.SonarQube/SonarQube.fs @@ -42,22 +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 orgArgs = + let arg flag param = + let augmentedParam = @""+ param + @"" + (sprintf "/%s:%s" flag augmentedParam).Trim() + + let organisationArgument = match parameters.Organization with - | Some (organization) -> (" /o:" + organization) - | None -> "" - - let cfgArgs = + | 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 + orgArgs - | End -> "end " + setArgs + cfgArgs - + | Begin -> beginCall.ToStartInfo + | End -> endCall.ToStartInfo let result = Process.execSimple ((fun info -> { info with