Coverage report not found when dotnet-sonar job run
## Describe the bug The opencover coverage report not found, because of strict file name configured in global script. ```bash coverage_reports="$(find "${DOTNET_PROJECT_DIR}" -name 'dotnet-test.opencover.xml' | sed 's|\./||g' | paste -sd',' -)" ``` There are cases where Opencover reports are generated with different name format then which is ecpected. Like below: ![image](/uploads/1f7cbabf5c723968c5475f4ebbe3bc19/image.png){width=874 height=201} And of course the script can not find them, beacause the search is made using filter `dotnet-test.opencover.xml` ## Expected behavior Locate the opencover reports required for Sonar scanning. If in `dotnet-build` job we have a section where the generated reports are copied and renamed like below, need to change the way how the reports are identified in `dotnet_run_sonar` function : ```bash report_name="dotnet-test-${DOTNET_PROJECT_NAME}-${project_dir}.${report_type}.${file_extension}" log_debug "Copying test report $(basename "$report_file") for project dir ${report_name}" # shellcheck disable=SC2086 cp "$report_file" "${DOTNET_PROJECT_DIR}/reports/${report_name}" ``` Possible solution: ```bash coverage_reports="$(find "${DOTNET_PROJECT_DIR}" -name 'dotnet-test-*.opencover.xml' | sed 's|\./||g' | paste -sd',' -)" ... xunit_reports="$(find "${DOTNET_PROJECT_DIR}" -name 'dotnet-test-*.xunit.xml' | sed 's|\./||g' | paste -sd',' -)" ``` ## Logs and/or screenshots ```bash [DEBUG] No code coverage reports found [DEBUG] dotnet-sonarscanner begin /k:sample-project /d:sonar.token=[MASKED] /d:sonar.host.url=https://sonarqube.example.com /d:sonar.cs.opencover.reportsPaths= /d:sonar.cs.xunit.reportsPaths=projects/dotnet-sample/UnitTest/bin/reports/dotnet-test.xunit.xml /d:sonar.qualitygate.wait=false /d:sonar.exclusions=**/app/**/*,**/*.sql,test/*,**/*.txt,**/*.http,**/sql/**,**/*.htm,**/*.cshtml,**/*.html,**/*.json,**/*.js,**/bin/**,**/obj/**,**/Views/**,**/Migrations/**,**/Properties/**,**/*.css,**/.dotnetcli/**,**/.dotnetcli/.nuget/**,**/.dotnetcli/.nuget/packages/** /d:sonar.cs.sarif.reportsPaths=projects/dotnet-sample/UnitTest/bin/dotnet-build.sarif,projects/dotnet-sample/dotnet-sample/bin/dotnet-build.sarif /d:sonar.coverage.exclusions=**/app/**/*,**/*.sql,test/*,**/*.txt,**/*.http,**/sql/**,**/*.htm,**/*.cshtml,**/*.html,**/*.json,**/*.js,**/bin/**,**/obj/**,**/Views/**,**/Migrations/**,**/Properties/**,**/*.css,**/.dotnetcli/**,**/.dotnetcli/.nuget/**,**/.dotnetcli/.nuget/packages/** /v:2.0.0 SonarScanner for .NET 11.1 Using the .NET Core version of the Scanner for .NET Pre-processing started. Preparing working directories... 08:16:56.44 Unrecognized command line argument: 08:16:56.457 Expecting at least the following command line argument: - SonarQube/SonarCloud project key The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for .NET. Use '/?' or '/h' to see the help message. 08:16:56.458 Pre-processing failed. Exit code: 1 ``` ## Context & Configuration [Link to file facing the bug](https://gitlab.com/to-be-continuous/dotnet/-/blob/main/templates/gitlab-ci-dotnet.yml?ref_type=heads#L924) The issue was reproduced using: * Version of the template: 2.2.3
issue