December 12, 2022, 8:43am
Recently, I have configured Jenkins and sonar for my ruby project.
Following are the below Jenkins and error details :
ERROR: Cannot read coverage report file, expecting standard SimpleCov JSON formatter output: '/home/jenkins/agent/workspace/ABC_PR-1239/coverage/coverage.json'
setting in spec_helper.rb
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
In coverage directory I can see below files,
What I want,
I have tried in my ways but nothing worked.
I expect my coverage results to reflect on sonar dashboard.
December 13, 2022, 9:26am
It sounds like something is wrong with the contents of
/home/jenkins/agent/workspace/ABC_PR-1239/coverage/coverage.json’. Does it look as expected to you?
This isn’t a valid SonarQube Version – check the footer of your SonarQube instance for the true version and report back!
December 13, 2022, 11:26am
Thanks for your reply.
Yes, the path which I have mentioned it’s Jenkin path.
and on root of my project I am generating coverage.json file
If I made any changes to this path then it gives below error,
ERROR: SimpleCov report not found: ‘coverage/coverage.json’
Below are the more details,
simplecov-html (0.12.3, 0.10.2)
simplecov_json_formatter (0.1.4, 0.1.3)
December 14, 2022, 4:40am
Can I get any example json file in standard SimpleCov JSON format. I will verify it by passing this.
Here is my generated coverage.json file for your reference.
coverage.json (4.3 KB)
December 14, 2022, 9:57am
Thanks. Let’s step back to this question again:
December 14, 2022, 10:02am
This I found in the footer.
Version 9.2.4 (build 50792)
December 14, 2022, 10:10am
Thanks. I would have expected a file that looks more like this one:
I’m not quite sure how you’ve landed on another format, except that the output you’ve shared seems to match
this JSON formatter rather than this one (which appears to be more closely tied to the simplecov project, and produces the expected format).
December 14, 2022, 10:42am
Yes, I have used
gem simplecov-json and it is generating
this JSON format. I will try by removing it and will check default simplecov’s generated JSON format.
December 15, 2022, 6:50am
Hi Colin, After removing
gem simplecov-json I can able to get data in suggested json format. Here, is file for your reference. But, still I am not able to see the coverage details in the dashboard. In logs, I didn’t find any error messages. Can you please help me what I am missing here.
coverage.json (12.9 KB)
December 16, 2022, 9:18am
Can someone help me on the above issue.
December 20, 2022, 11:20am
Can you share the full logs from analysis (the output from the scanner, where you are now passing the new coverage report), and a screenshot of where you see 0% coverage being reported in SonarQube?
December 22, 2022, 11:06am
Hi Colin, This issue is fixed after merging in master branch. Now, I can see the code coverage. Thanks for your help