Error during parsing of coverage report - caused by unknown XML node - C/C++

Hello,

I am having a new issue since the upgrade of SonarCloud on March 26th, 2022. It seems like I have an issue with the parsing of our generic coverage report.

Here is what I am using:

  • SonarCloud (scanner version 4.7.0.2747)
  • Bitbucket Pipelines
  • C/C++ project compiled with CMake
  • GoogleTests as a unit testing suit

The error I get is:

`ERROR: Error during SonarScanner execution`

`ERROR: Error during parsing of the generic coverage report '/opt/atlassian/pipelines/agent/build/test-coverage.xml'. Look at SonarQube documentation to know the expected XML format.`

`ERROR: Caused by: Unknown XML node, expected "lineToCover" but got "functionToCover" at line 2`

I am calling the SonarCloud analysis from Bitbucket Pipelines. Here is how my minimal pipeline step looks like:

          - export SONAR_SCANNER_VERSION=4.7.0.2747
          - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
          - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
          - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
          - export PATH=$SONAR_SCANNER_HOME/bin:$PATH
          - export SONAR_SCANNER_OPTS="-server"
          - curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
          - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
          - export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
          # Install node.js
          - curl -sL https://deb.nodesource.com/setup_16.x | bash -
          - apt-get install -y nodejs
          # Install code coverage tools
          - apt-get install -y python3-pip
          - pip3 install -U gcovr
          - gcovr --version
          #  Install CMake
          - apt-get update -qq
          - pip3 install cmake
          # Build library for testing and scanning Sonar Cloud
          - mkdir build_wrapper_output_directory
          - cmake -DCMAKE_BUILD_TYPE=Debug
          - build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory make clean all
          - tests/Google_Tests_run --gtest_output=xml:test-results/test_outputs.xml
          - gcovr -r . --sonarqube -o test-coverage.xml
          #scan
          - sonar-scanner 

My sonar-project.properties specifies those entries:

sonar.organization=
sonar.projectKey=
sonar.sources=
sonar.cfamily.build-wrapper-output=
sonar.host.url=
sonar.coverageReportPaths=
sonar.cfamily.threads=
sonar.cfamily.cache.enabled=
sonar.projectVersion=

This solution was working properly before the latest SonarCloud upgrade. Has anyone any idea on how to make setup this pipeline to make it properly work again?

Thank you very much for your help,

Sakura

1 Like

I found a solution to my issue: the latest update of gcovr was making the file incompatible for Sonar to read the result of the generic file.

To install an older version of sonar, I had to install an older version of Python.

So I updated

pip3 install -U gcovr

with

pip install gcovr

And then all pip3 instructions by pip

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.