Hello. This is new topic based on previously created Quality Gate Failure After Renaming Projects in Azure DevOps Description:
I encountered a Quality Gate failure with 0% coverage after renaming projects in my Azure DevOps environment. Here are the details:
ALM Used: Azure DevOps
CI System: Azure DevOps
Languages of the Repository: C#
Issue:
The coverage is reported as zero, which likely caused the Quality Gate failure. Although I didn’t write any new code, I did rename the projects. Consequently, I had to remove and re-add them. Additionally, I fixed all the build files after renaming the projects.
Solution Structure Before Renaming:
Solution (abc)
ProjectA
ProjectB
ProjectC
Renamed Solution:
Solution (xyz)
ProjectX
ProjectY
ProjectZ
Logs with sonar.log.level “INFO” level should be enough? Or more verbose level should be used here? Thanks
Are you sure you’re still generating coverage reports after all the projects have moved around? What do the logs say about the import of coverage reports?
Hello. I didn’t find any suspicious in the logs. Coverage .coverage reports are exists in build agent temp folder and looks like a sonar scanner picked them off to analyze.
Here is logs-zero-coverage.txt where 0.0% coverage after renaming a project.
and logs-coverage.txt before renaming project. logs-coverage.txt (60.0 KB) logs-zero-coverage.txt (60.1 KB)
It’s weird that both logs seem to show files parsing successfully, but the latter (0% coverage) don’t show this line:
2024-06-03T13:30:52.0371181Z INFO: Coverage Report Statistics: 468 files, 468 main files, 468 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.
2024-06-03T13:30:52.0371623Z INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=648ms
A few other things have changed that are unrelated to renaming of your projects.
For example it looks like you’ve moved to SonarCloudAnalyze@V2
Before:
2024-06-03T13:29:38.4301002Z ##[section]Starting: SonarCloud Run
2024-06-03T13:29:38.4371017Z ==============================================================================
2024-06-03T13:29:38.4371354Z Task : Run Code Analysis
2024-06-03T13:29:38.4371431Z Description : Run scanner and upload the results to the SonarCloud server.
2024-06-03T13:29:38.4371572Z Version : 1.45.0
2024-06-03T13:29:38.4371639Z Author : sonarsource
2024-06-03T13:29:38.4371758Z Help : Version: 1.45.0. This task is not need
After:
2024-06-06T11:41:05.2822070Z ##[section]Starting: SonarCloud Run
2024-06-06T11:41:05.2831020Z ==============================================================================
2024-06-06T11:41:05.2831190Z Task : Run Code Analysis
2024-06-06T11:41:05.2831286Z Description : Run scanner and upload the results to the SonarCloud server.
2024-06-06T11:41:05.2831451Z Version : 2.0.0
2024-06-06T11:41:05.2831514Z Author : sonarsource
2024-06-06T11:41:05.2831658Z Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
Can you change your Prepare Analysis Configuration and Run Code Analysis tasks back to @V1 to see if it fixes the coverage issue? There would still be an issue for us to investigate, but at least we can be sure where the issue is.
For some reason when I switched to v1 I got an error. I didn’t faced with this issue before, when I run analysis with v1 task sonar tasks from feature branch… logs-v1-sonartask-failed.txt (59.5 KB)