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

I am trying to integrate SonarQube in a CI-pipeline in Azure DevOps. I used the exact configuration that I used in other pipelines where everything runs smoothly. However, this pipeline can’t find the analysis in the SonarQube Publish step as shown in the logs below.

##[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.

I find this problem hard to solve because it seems like the analysis report is there but after applying the include pattern there are zero matches. The pipeline contains the following steps:

- stage: 
  - job: Build_Restore_and_Run_Unit_Tests
      vmImage: ubuntu-latest
    - task: SonarQubePrepare@5
      displayName: SonarQube
        SonarQube: SonarQube
        scannerMode: MSBuild
        projectKey: $(sonarQubeProjectKey)
        projectName: $(sonarQubeProjectName)
        extraProperties: |
    - task: DotNetCoreCLI@2
      displayName: Restore
        command: 'restore'
        projects: 'src/**/*.csproj'
        feedsToUse: 'select'
        vstsFeed: '989127ec-b6ef-4c8c-ae54-90dec743281d'

    - task: DotNetCoreCLI@2
      displayName: Build
        command: build
        projects: |
        arguments: '--configuration $(buildConfiguration) --no-restore'

    - task: DotNetCoreCLI@2
      displayName: Test
        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
        codeCoverageTool: Cobertura
        summaryFileLocation: $(Agent.TempDirectory)/*/coverage.cobertura.xml
    - task: SonarQubeAnalyze@5
      displayName: Run code analysis
    - task: SonarQubePublish@5
      displayName: Publish quality gate result
        pollingTimeoutSec: '300'

My attempts to fix this issue:

  • Currently I am using ubuntu-latest. I have tried a Windows image.
  • Applied time-outs.
  • Upgraded the SonarQube steps from major version 4 to 5.
  • Added an unique GUID to each projects csproj.

Hello and welcome to the community!

Please give us the following version information:

  • what is the version of SonarQube that you are using?
  • what is the version of the Scanner for .NET (MSBuild) that you are using?
  • what version of MSBuild are you using?

And we’ll need the logs:

  • please give us the verbose output of the scanner commands (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of the BEGIN and END steps)
  • please give the output of running MSBuild in verbose mode (/v:d)

Also, please tell us:

  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?

In addition, please see the following guides:

Hi Andrei, many thanks for your reply!

The requested information:

  • SonarQube version: Version 8.9.3 (build 48735) Community Edition;
  • SonarScanner for Azure DevOps version 5.4.0 (which uses the SonarScanner for MSBuild 5.5.3);
  • Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET.

The requested logs (sensitive information is anonymized with **):

The requested commands:

  • SonarQube prepare: /usr/bin/dotnet /home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.4.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll begin /k:** Project name **
  • SonarQube analyze: /usr/bin/dotnet /home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.4.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll end

@yuri_vanruler the logs for the end step suggest that the analysis is being uploaded successfully for the Sonar server. Can you see the analysis results on the server?

@duncanp that is right, newly created code is published succesfully to the Sonar server. The tab ‘Code’ shows new lines (random statements in a test) of code. However the tab ‘Overview > Measures’ where analysis results are shown stays empty, I don’t know if this is correct. Besides that, the main problem persists: the analysis still can’t be found in the CI-pipeline at the Publish Quality Gate Result step. The logs are similar as the extended logging in my original post. I added some more screencaptures below.

Hi @yuri_vanruler

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).

I would suggest to avoid brackets in the name of the build, as a workaround.



Hi @mickaelcaro,

Wow thank you! This problem persisted for over two months. I changed the characters from [ ] to ( ). The analysis runs perfectly now!

Kind regards, Yuri


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.