cake-contrib / Cake.Sonar

:cake: :jigsaw: Cake addin to execute the MSBuild scanner for SonarQube in Cake builds
https://cakebuild.net/extensions/cake-sonar/
MIT License
31 stars 24 forks source link

Add possibility for custom properties #71

Closed WebDucer closed 6 years ago

WebDucer commented 6 years ago

Sonar has a lot of plugins with its own configuration. Please add the possibility to add this in generic way (something like MSBuildSettings with WithProperty(string, string[]) extension mehtod). In my case, I want to add the project id for the GitLab repository of the analysed project (sonar.gitlab.project_id).

papauorg commented 6 years ago

Hi @WebDucer, I think that the SonarBeginSettings allow to add generic parameters by using the ArgumentCustomization property. This is implemented on the ToolSettings base class and the Cake.Sonar addin also adds the contents to the command line when executing the runner tool.

So in order to add your custom property you can just do the following:

SonarBegin(new SonarBeginSettings{
       /* Regular Settings Here */
       ArgumentCustomization = args => args
            .Append("/d:sonar.gitlab.project_id=XXXX")
            .Append("/d:sonar.gitlab.xxx=XXXX")
});

Please note the /d: in front of the actual settings name.

I didn't try if it actually works, only that the settings are also passed to the runner (by the --verbosity=diagnostic switch).

Best regards, Philipp

WebDucer commented 6 years ago

Thanks. I will try it out.