Hallo together ,
accedently I have gotten the task to display the code coverage to an sonar.cloud results page.
The code coverage is displayed in the coverage Tab in the Pipleine tabs,
but not in the Sonarclod quality gate.
i have the following prepare task
- task: SonarCloudPrepare@1
condition: and(succeeded(), eq(variables.performSonarAnalysis, 'true'))
inputs:
SonarCloud: 'SonarCloud'
organization: 'ksca'
scannerMode: 'MSBuild'
projectKey: 'KSCA_OurWCS'
projectName: 'OurWCS'
extraProperties: |
sonar.cobertura.reportPaths='$(Agent.TempDirectory)/**/coverage.cobertura.xml'
sonar.exclusions=**/obj/**,**/*.dll
sonar.cs.xunit.reportsPaths=${Agent.TempDirectory}/**/XUnit.TestResults.xml
#sonar.cs.opencover.reportsPaths=${Agent.WorkFolder}/coverage/$(OPENCOVER_OUTPUT)
sonar.cs.opencover.reportsPaths=${Agent.WorkFolder}/coverage/opencoverCoverage.xml
sonar.sourceEncoding=UTF-8
sonar.verbose=true
in the test step
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: 'test'
projects: '**/*.csproj'
#arguments: '--no-restore --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(Build.SourcesDirectory)/coverage/'
arguments: '--configuration $(BuildConfiguration) --no-build /p:CollectCoverage=true /p:settings=.runsettings.xml /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(Agent.WorkFolder)/coverage/$(OPENCOVER_OUTPUT) /p:MergeWith=$(Agent.WorkFolder)/coverage/ --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura'
publishTestResults: true
during test step in the logs there are is many times appearing entries like
Calculating coverage result...
Generating report '/home/vsts/work/coverage/opencoverCoverage.xml'
then we have a step that creates and puplishes code coverage to pipeline
# First install the tool on the machine, then run it
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.1.13
reportgenerator -reports:$(Agent.WorkFolder)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CoverageResults -reporttypes:'HtmlInline_AzurePipelines;Cobertura'
displayName: Create code coverage report
but in the analyze step
i get the following
6 WARN: Could not find any coverage report file matching the pattern '/coverage/opencoverCoverage.xml'
Wht am I doing wrong ?
TIIA
Martin