Add or remove analysis parameter to dotnet-sonarscanner after begin and before end

I have the begin command where I add the analysis parameter coverageReportsPaths
Next build the dotnet project
Next run tests of dotnet project which generates coverage report
Run reportgenerator to convert the coverage report to sonarqube format
Finally I have the end command.

All looks fine as works fine as long as the project has test cases.

In my case where there is no test cases, I know that only when I run the tests and no coverage report is generated. Based on the availability of coverage report I want to add or remove the analysis parameter of coverageReportsPaths from the begin.

Hi,

Welcome to the community!

That build scripting is outside the scope of this community.

That said, the absence of a coverage report doesn’t cause analysis to fail, does it?

 
Ann

Yes. Below is the option I gave during dotnet sonarscanner begin

/d:sonar.coverageReportPaths=“${COVERAGE_RESULT_FOLDER}SonarQube.xml” \

It failed with the below message:

If I dont give the above coverageReportPaths option then it is good as expected.

I will be sending the coverageReportPaths option. what I am expecting is, If it finds the file then it should do the coverage report, else it should say zero coverage report and complete the scan successfully.

Hi,

Ah, right. That’s fail-fast.

In fact, we have an inconsistency here. If a language-specific coverage report is missing, you get a message in the logs, but analysis doesn’t fail.

I’m going to raise this internally, but I doubt anything will change any time soon.

 
Thx,
Ann

Hi, I have raised the question here on our side.

As a stopgap measure, may I suggest generating a default file with only the root node inside when you have no tests?

<coverage version=“1”>
</coverage>
I cannot guarantee this will work, and I understand this is not ideal, but it could be enough to keep your workflow going the way you want it to.

Denis