'Convert cobertura-coverage.xml to sonar analyze

I am coding in vuejs and using cobertura to check the coverage When i run tests "test": "NODE_ENV=test jest --reporters=jest-junit --reporters=default --coverage" from package.json, a cobertura-coverage.xml is created.

cobertura-coverage.xml looks like that :

<?xml version="1.0" ?>                                                                
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage lines-valid="142" lines-covered="1" line-rate="0.006999999999999999" branches- 
 valid="222" branches-covered="2" branch-rate="0.009000000000000001" timestamp="1653295178576" 
 complexity="0" version="0.1">
<sources>
<source>C:\Users\me\Documents\VisualCode\front</source>
</sources>
<packages>
<package name="components" line-rate="0.14279999999999998" branch-rate="0.3333">
  <classes>
    <class name="breadcrumb.vue" filename="components\breadcrumb.vue" line-rate="0" branch- 
  rate="1">
      <methods>
        <method name="(anonymous_0)" hits="0" signature="()V">
          <lines>
            <line number="1" hits="0"/>
          </lines>
        </method>
      </methods>
      <lines>
        <line number="1" hits="0" branch="false"/>
      </lines>
    </class>

Finally, when I run the pipeline on gitlab, I have this error message :

ERROR: Caused by: Unknown XML node, expected "file" but got "sources" at line 4

I have read that it is because sonar doesn't support this xml format and by installing a plugin it could be possible but i have no idea of how to do it.

Any help is welcomed



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source