Skip to content

Commit

Permalink
Allow to pass parameter to sonarqube end
Browse files Browse the repository at this point in the history
Useful when using SonarQub public server with token.
And add simple method for SonarQubeEnd without arguments
  • Loading branch information
Jérémie Bertrand committed Sep 18, 2016
1 parent 73589a8 commit 688bf33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions FAKE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "help", "help", "{564BD198-0
help\nuget.md = help\nuget.md
help\octopusdeploy.md = help\octopusdeploy.md
help\slacknotification.md = help\slacknotification.md
help\sonarcube.md = help\sonarcube.md
help\specifictargets.md = help\specifictargets.md
help\teamcity.md = help\teamcity.md
help\templates\template-project.html = help\templates\template-project.html
Expand Down
10 changes: 3 additions & 7 deletions help/sonarcube.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@ compilation has finished. Then the result is collected and send to the SonarQube
## Minimal working example

Target "BeginSonarQube" (fun _ ->

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

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

Target "Default" DoNothing

Expand Down
18 changes: 13 additions & 5 deletions src/app/FakeLib/SonarQubeHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,24 @@ let SonarQubeDefaults =
let SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
let sonarPath = parameters.ToolsPath
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"
| End -> "end " + setArgs + cfgArgs

let result =
ExecProcess (fun info ->
info.FileName <- sonarPath
info.Arguments <- args) System.TimeSpan.MaxValue
if result <> 0 then failwithf "Error during sonar qube call %s" (call.ToString())

/// This task to can be used to run [Sonar Qube](http://conarqube.org/) on a project.
/// This task to can be used to run [Sonar Qube](http://sonarqube.org/) on a project.
/// ## Parameters
///
/// - `call` - Begin or End, to start analysis or finish it
Expand All @@ -71,3 +70,12 @@ let SonarQube (call: SonarQubeCall) setParams =
let parameters = setParams SonarQubeDefaults
SonarQubeCall call parameters
traceEndTask "SonarQube" (call.ToString())

/// This task can be used to run the end command of [Sonar Qube](http://sonarqube.org/) on a project.
///
/// ## Sample
/// SonarQubeEnd
///
let SonarQubeEnd() =
SonarQube End (fun p -> { p with Settings = [] })

2 comments on commit 688bf33

@AtwoodTM
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest update is causing errors vs version 4.39.1. Specifically, sonar settings now being flagged as errors:

This setting is not valid the "end" phase in this version of the C# plugin: sonar.log.level
This setting is not valid the "end" phase in this version of the C# plugin: sonar.verbose
This setting is not valid the "end" phase in this version of the C# plugin: sonar.branch
This setting is not valid the "end" phase in this version of the C# plugin: sonar.cs.xunit.reportsPaths
This setting is not valid the "end" phase in this version of the C# plugin: sonar.opencover.reportsPaths

This happens when calling SonarQube end. Will open an issue and will note the issue number...

@laedit
Copy link
Contributor

@laedit laedit commented on 688bf33 Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is because the previous version forced to pass parameters to the end call, even if they were not used.
The only parameter used in the end call is sonar.login, you should remove the others.
Or use SonarqubeEnd() if you haven't the use of sonar.login.

Please sign in to comment.