SonarQube analysis fails for C# code in pilepilne

Hi everyone,
I followed the instruction on this link and connected the project to my pipeline but it fails. I have no idea what the issue is.
Feels like it says it cannot find the pull request key.
I am using the community version (9.5). Can someone please guild me on what the issue could be?

YML fike

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'

jobs:
  - job: Build
    steps:
    - task: DotNetCoreCLI@2
      displayName: 'Restore'
      inputs:
        command: 'restore'
        projects: '**/*.csproj'
        feedsToUse: 'select'
    - task: SonarQubePrepare@5
      inputs:
        SonarQube: 'SonarQube'
        scannerMode: 'MSBuild'
        projectKey: 'E************7vIFzEYGi2'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
        command: 'build'
        projects: '**/*.csproj'
        arguments: '--no-restore -p:RuntimeIdentifiers=win7-x64 --configuration Release'
    - task: SonarQubeAnalyze@5
    
    - task: SonarQubePublish@5
      inputs:
        pollingTimeoutSec: '300'
    - task: DotNetCoreCLI@2
      displayName: Test
      inputs:
        command: 'test'
        projects: '**/*Tests.csproj'
        arguments: '--configuration Release -- RunConfiguration.TargetPlatform=x64'
        testRunTitle: 'Lib**** CI Test'

  - job: WaitingApproval
    dependsOn: Build
    pool: server
    timeoutInMinutes: 1000
    steps:
    - task: ManualValidation
      inputs:
        notifyUsers: 'b****d@e***.io'
        instructions: 'Please check Sonar dashboard'

Error result

Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: D:\a\1\TestResults
No test results files found
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in D:\a\_temp
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
The TFS Processor has finished
Calling the SonarScanner CLI...
INFO: Scanner configuration file: D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.5.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.15 Eclipse Adoptium (64-bit)
INFO: Windows Server 2022 10.0 amd64
INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
INFO: Scanner configuration file: D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.5.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
INFO: Analyzing on SonarQube server 9.5.0.56709
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=130ms
INFO: Server id: 86E1FA4D-AYFilepI1oHXLfzpArYy
INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=75ms
INFO: Load/download plugins (done) | time=1889ms
INFO: Process project properties

Hi @Behdad_Kardgar ,

Is this build initiated by a Pull Request by any chance? If so, SonarQube automatically sets the appropriate parameters for the PR key, code branch, and compare branch. This is only supported in the Developer Edition of SonarQube or above, not in the Community Edition.

You’ll need to scan the code from a pipeline that was triggered either manually or through a code commit, not via a PR.

1 Like

Thank you @cba,
I will do as you suggested.
Best regards

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