Skonfigurowałem rurociąg na żądanie pull w Azure Devops, które obejmą analizę Sonarque.

Rurociąg buduje, przetestuj i analizuj projekty .NET Core. Po wykonaniu budowy Sonarqube zawiera wyniki analizy, ale nie informacje o pokryciu.

ramy testowe : mstest

sonarqube : Developer Edition Wersja 8.0 (Twoi 29455)

Pull Request.yaml.

pool:
  vmImage: 'windows-latest'

steps:
- script: echo Pull Request Pipeline
  displayName: 'Pull Request Pipeline'

- task: SonarQubePrepare@4
  inputs:
    SonarQube: 'SonarQube Connection'
    scannerMode: 'MSBuild'
    projectKey: 'ProjectKey'
    projectName: 'ProjectName'
    extraProperties: |
      sonar.scm.exclusions.disabled
      sonar.language=csharp
      sonar.log.level=TRACE
      sonar.verbose=true
      sonar.pullrequest.base=master
      sonar.pullrequest.key=$(System.PullRequest.PullRequestId)
      sonar.pullrequest.branch=$(Build.SourceBranchName)
      sonar.cs.vscoveragexml.reportsPaths=**\*.coveragexml

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '-c release'

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: '**/*.csproj'
    arguments: '-c release --no-build --collect:"Code Coverage"'

- task: SonarQubeAnalyze@4

- task: SonarQubePublish@4
  inputs:
    pollingTimeoutSec: '300'

Test Dotnet tworzy plik zasięgu i Codecoverage.exe tworzy plik zasilającyxml, ale Sonarqube nie znajduje plik CoveragexML.

Microsoft (R) Coverage Collection Tool Version 16.0.30319.3002


Copyright (c) Microsoft Corporation.  All rights reserved.




Results File: d:\a\_temp\VssAdministrator_fv-az623_2019-12-05_13_18_24.trx

Attachments:
  d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9\VssAdministrator_fv-az623_2019-12-05.13_18_22.coverage
Test Run Successful.

... 

Config file: d:\a\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml
13:18:27.568  Attempting to locate the CodeCoverage.exe tool...
13:18:27.583  Attempting to locate the CodeCoverage.exe tool using setup configuration...
13:18:27.833  Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
13:18:27.849  Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
13:18:27.849  Did not find any binary coverage files in the expected location.
13:18:27.849  Falling back on locating coverage files in the agent temp directory.
13:18:27.849  Searching for coverage files in d:\a\_temp
13:18:27.849  All matching files: count=2
13:18:27.849    d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9\VssAdministrator_fv-az623_2019-12-05.13_18_22.coverage
13:18:27.849    d:\a\_temp\VssAdministrator_fv-az623_2019-12-05_13_18_24\In\fv-az623\VssAdministrator_fv-az623_2019-12-05.13_18_22.coverage
13:18:27.849  Unique coverage files: count=1
13:18:27.849    d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9\VssAdministrator_fv-az623_2019-12-05.13_18_22.coverage
13:18:27.958  Executing file C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9\VssAdministrator_fv-az623_2019-12-05.13_18_22.coveragexml d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9\VssAdministrator_fv-az623_2019-12-05.13_18_22.coverage 
  Working directory: d:\a\_temp\ea5c681a-654c-4370-b748-d7264b53a0d9
  Timeout (ms):60000
  Process id: 5452
13:18:28.161  Process returned exit code 0

...

13:18:57.004 INFO: Sensor C# [csharp] (done) | time=529ms
13:18:57.004 INFO: Sensor C# Tests Coverage Report Import [csharp]
13:18:57.004 WARN: Could not find any coverage report file matching the pattern 'd:\a\1\b\**\*.coveragexml'.
13:18:57.004 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=0ms
13:18:57.004 INFO: Sensor C# Unit Test Results Import [csharp]
13:18:57.019 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=15ms

Co jest nie tak z rurociągiem YML?

3
DerDani81 5 grudzień 2019, 16:07

1 odpowiedź

Najlepsza odpowiedź

reportsPaths był nie tak.

To działa dla mnie:

sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)\**\*.trx
sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)\**\*.coveragexml
2
DerDani81 5 grudzień 2019, 13:54