SonarQube 9.7.0.61563
Sonar dotnet scanner: latest
Having a lot of trouble troubleshooting why my test results are not being uploaded and are being rejected by the scanner. Error is:
INFO: Parsing /builds/rocket/boost/src/TestResults/cypress/sonar-generic.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:18.027s
INFO: Final Memory: 19M/70M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of generic test execution report '/builds/rocket/boost/src/TestResults/cypress/sonar-generic.xml'. Look at the SonarQube documentation to know the expected XML format.
ERROR: Caused by: /builds/rocket/boost/src/TestResults/cypress/sonar-generic.xml (No such file or directory)
ERROR:
The SonarScanner did not complete successfully
Here is how I am referring the file:
- apt-get install --yes openjdk-11-jre
- dotnet tool install --global dotnet-sonarscanner
- dotnet sonarscanner begin /k:"$SONAR_PROJECT" /d:sonar.login="$SONAR_TOKEN" /d:sonar.host.url="$SONAR_HOST_URL"
/d:sonar.sources="src"
/d:sonar.exclusions="$SONAR_CODE_EXCLUSIONS"
/d:sonar.tests="src"
/d:sonar.test.inclusions="$SONAR_TEST_INCLUSIONS"
/d:sonar.cs.vstest.reportsPaths="${CI_PROJECT_DIR}/src/TestResults/csharp/*.trx"
/d:sonar.testExecutionReportPaths="${CI_PROJECT_DIR}/src/TestResults/react/sonar-generic.xml,${CI_PROJECT_DIR}/src/TestResults/cypress/sonar-generic.xml"
/d:sonar.coverage.exclusions="$SONAR_COVERAGE_EXCLUSIONS"
/d:sonar.coverageReportPaths="${CI_PROJECT_DIR}/src/TestResults/SonarQube.xml"
- dotnet build --configuration:$BUILD_CONFIGURATION src/$SOLUTIONNAME
# No need to run tests here, just include the test and coverage reports created from all previous jobs
- dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"
The file /builds/rocket/boost/src/TestResults/cypress/sonar-generic.xml
definitely exists at that point in the build.
The file I am trying to upload looks like this (UTF-8, LF)
<?xml version="1.0" encoding="utf-8"?>
<testExecutions version="1">
<file path="/builds/rocket/boost/src/WebsiteHost.UITests/cypress/e2e/bookings.cy.ts">
<testCase name="Given a registered car - when create a booking, then booking added" duration="14127"></testCase>
</file>
<file path="/builds/rocket/boost/src/WebsiteHost.UITests/cypress/e2e/cars.cy.ts">
<testCase name="Given no cars - when create new car, then unregistered car added" duration="6736"></testCase>
</file>
<file path="/builds/rocket/boost/src/WebsiteHost.UITests/cypress/e2e/login.cy.ts">
<testCase name="Given an unauthenticated user - when access homepage, then loads login page" duration="1734"></testCase>
<testCase name="Given a unverified user - when login, then shows error" duration="3964"></testCase>
<testCase name="Given an authenticated user - when login successful, then goes to home page" duration="4268"></testCase>
<testCase name="Given an authenticated user - when logout, then goes back to login page" duration="4059"></testCase>
</file>
<file path="/builds/rocket/boost/src/WebsiteHost.UITests/cypress/e2e/password.cy.ts">
<testCase name="Given a unverified user - when forgot password, and not verified then error" duration="2988"></testCase>
<testCase name="Given a registered user - when forgot password, reset password and login with new password, then can access homepage" duration="8716"></testCase>
<testCase name="Given a registered user - when forgot password, and token expired then resend" duration="2362"></testCase>
<testCase name="Given a registered user - when forgot password, and token used then success" duration="1976"></testCase>
</file>
<file path="/builds/rocket/boost/src/WebsiteHost.UITests/cypress/e2e/registration.cy.ts">
<testCase name="Given an unauthenticated user - when on-boarded, then can access homepage" duration="9227"></testCase>
</file>
</testExecutions>
This file is produced by the npm package cypress-sonarqube-reporter
What I have tried?
lots of things, oh boy!
However, the only real clue I have is that: if I run the exact same scanner commands and build on my local Windows 11 machine, the same file is produced (albeit with different paths), and it uploads without error.
When run on our gitlab CI server (which is a linux docker container) it fails. As described above.
Apart from the differences in paths, the files are identical. AFAICT
Please help me resolve? this is super frustrating.