SonarQube:应用包含模式后在此构建中未找到分析

SonarQube: No analysis found in this build after applying include pattern

我正在尝试将 SonarQube 集成到 Azure DevOps 的 CI 管道中。我使用了我在其他一切顺利运行的管道中使用的确切配置。但是,此管道无法在 SonarQube Publish 步骤中找到分析,如下面的日志所示。

##[debug]  /home/vsts/work/_temp/sonar (directory)
##[debug]  /home/vsts/work/_temp/sonar/Company.Service-CI[sonarqube-test][121226][2022-01-19] (directory)
##[debug]  /home/vsts/work/_temp/sonar/Company.Service-CI[sonarqube-test][121226][2022-01-19]/9731b11b-6af8-d211-752d-e8fe0770156c (directory)
##[debug]  /home/vsts/work/_temp/sonar/Company.Service-CI[sonarqube-test][121226][2022-01-19]/9731b11b-6af8-d211-752d-e8fe0770156c/report-task.txt (file)
##[debug]4 results
##[debug]found 4 paths
##[debug]applying include pattern
##[debug]adjustedPattern: '/home/vsts/work/_temp/sonar/Company.Service-CI[sonarqube-test][121226][2022-01-19]/**/report-task.txt'
##[debug]0 matches
##[debug]0 final results
##[debug][SQ] Searching for sonar/Company.Service-CI[sonarqube-test][121226][2022-01-19]/**/report-task.txt - found 0 file(s)
##[warning]No analyses found in this build! Please check your build configuration.

我发现这个问题很难解决,因为分析报告似乎在那里,但在应用包含模式后,匹配项为零。该管道包含以下步骤:

stages:
- stage: 
  jobs:
  - job: Build_Restore_and_Run_Unit_Tests
    pool:
      vmImage: ubuntu-latest
    steps:
    - task: SonarQubePrepare@5
      displayName: SonarQube
      inputs: 
        SonarQube: SonarQube
        scannerMode: MSBuild
        projectKey: $(sonarQubeProjectKey)
        projectName: $(sonarQubeProjectName)
        extraProperties: |
          sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/*/coverage.opencover.xml
        
    - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
        command: 'restore'
        projects: 'src/**/*.csproj'
        feedsToUse: 'select'
        vstsFeed: '989127ec-b6ef-4c8c-ae54-90dec743281d'

    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        command: build
        projects: |
              **/*.Test.csproj
        arguments: '--configuration $(buildConfiguration) --no-restore'

    - task: DotNetCoreCLI@2
      displayName: Test
      inputs:
        command: test
        projects: '**/*.Test.csproj'
        nobuild: true
        arguments: '--no-restore --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura,opencover'
        publishTestResults: true
        
    - task: PublishCodeCoverageResults@1
      displayName: Publish code coverage
      inputs:
        codeCoverageTool: Cobertura
        summaryFileLocation: $(Agent.TempDirectory)/*/coverage.cobertura.xml
        
    - task: SonarQubeAnalyze@5
      displayName: Run code analysis
    
    - task: SonarQubePublish@5
      displayName: Publish quality gate result
      inputs:
        pollingTimeoutSec: '300'

我解决这个问题的尝试:

正如 Mickaël Caro 在 SonarSource 社区论坛 my similar post 上所说:

Unfortunately some characters are not recognized nor parsed correctly when we try to find the report path (We do have this issue filed here : [VSTS-240] Escape regex characters when finding report path file. - SonarSource).

我把构建名称中的[ ]改成了( ),分析很顺利