2đź‘Ť
I think the problem is that there seem to be no link between Sonar and Jenkins. It would be easier to make it with plugins.
After installing plugins you’d just have to add a build step in the jenkins administration.
In order to see the coverage report in Sonar you should use the “Jenkins Sonar Plugin”. However it will force you to create a maven project (and a pom.xml) and as you’re using Django (which already does what maven does), it may not be what you want.
I think what you want is seeing the code coverage somewhere and maybe you should integrate it in Jenkins instead of Sonar. To do so you can use two plugins, “Jenkins Cobertura Plugin” and the “HTML Publisher plugin”.
Jenkins Cobertura Plugin will allow you to see graphically the code coverage from your coverage.xml. You can see the percentage covered in package, file, classe, line, and conditionnal. You’ll just have to add the link to your coverage.xml into Jenkins in your project administration. More detail here.
HTML Publisher plugin] will probably be useful to see the detailled code coverage by publishing the coverage report in html.
0đź‘Ť
On Jenkins I found that coverage.xml has paths that are relative to the directory in which manage.py jenkins is run.
In my case I need to run unit tests on a different machine than Jenkins. To allow Sonar to use the generated coverage.xml, it was necessary for me to run the tests from a folder in the same spot relative to the project as the workspace directory on Jenkins.
Say I have the following on Jenkins /local/jenkins/tmp/workspace/my_build + my_project + app1 + app2 Say on test machine I have the following /local/test + my_project + app1 + app2
I run unit tests from /local/test on the test machine. Then coverage.xml has the correct relative paths, which look like my_project/app1/source1.py or my_project/app2/source2.py
-1đź‘Ť
I think problem with:
sonar.cobertura.reportPath=/var/lib/jenkins/workspace/origami/DEV/SRC/origami/reports/coverage.xml
Read this: link
- [Django]-Django session lost when redirected from facebook oauth
- [Django]-.js files not included in page when using Django Form Assets (Media class) with crispy forms
- [Django]-Django localization: labels don't get updated
- [Django]-Fake subfunction in django UnitTest Case (Mocking)