Facing issue with sonarqube

Below is the yaml file and error we are facing,

2024-08-09T12:06:23.9204209Z ##[section]Starting: SonarQubeAnalyze
2024-08-09T12:06:23.9210465Z ==============================================================================
2024-08-09T12:06:23.9210856Z Task         : Run Code Analysis
2024-08-09T12:06:23.9211088Z Description  : Run scanner and upload the results to the SonarQube server.
2024-08-09T12:06:23.9211329Z Version      : 6.3.2
2024-08-09T12:06:23.9211551Z Author       : sonarsource
2024-08-09T12:06:23.9211814Z Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/)
2024-08-09T12:06:23.9212336Z ==============================================================================
2024-08-09T12:06:24.1123067Z ##[warning]Error while executing SonarQube:Analyze task: ENOENT: no such file or directory, chmod '/home/vmuser-uls/myagent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/6.3.2/sonar-scanner/bin/sonar-scanner'
2024-08-09T12:06:24.1136215Z ##[error]ENOENT: no such file or directory, chmod '/home/vmuser-uls/myagent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/6.3.2/sonar-scanner/bin/sonar-scanner'
2024-08-09T12:06:24.1148131Z ##[section]Finishing: SonarQubeAnalyze

Yaml

stages:
- stage: Build
  jobs:
  - job: Build
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '8.x'
        installationPath: $(Agent.ToolsDirectory)/dotnet
    - task: SonarQubePrepare@6
      inputs:
        SonarQube: 'sonarqube'
        scannerMode: 'CLI'
        configMode: 'manual'
        cliProjectKey: **'
        cliSources: '**'
   
    - script: |
        docker build -t $(acrLoginServer)/$(imageName):$(imageTag)-$(DATE_TAG) .
      displayName: 'Build Docker Image'
    - task: SonarQubeAnalyze@6
      inputs:
        jdkversion: 'JAVA_HOME'
    - task: SonarQubePublish@6
      inputs:
        pollingTimeoutSec: '300'

Hey there.

I’m really curious if there’s an order of operations thing going on here. Can you try moving SonarQubeAnalyze right after SonarQubePrepare (before the Docker build) and see if makes a difference?

Hi Colin still getting the same issue

trigger:
- main

pool: 
  name: default
  vmImage: 'ubuntu-latest'

variables:
  imageTag: '$(Build.BuildId)'
  imageName: 'uls'
  acrName: 'ulsacr'
  acrLoginServer: 'ulsacr.azurecr.io'
  DATE_TAG: $(date +%Y%m%d)

stages:
- stage: Build
  jobs:
  - job: Build
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '8.x'
        installationPath: $(Agent.ToolsDirectory)/dotnet

    - task: SonarQubePrepare@6
      inputs:
        SonarQube: 'sonarqube'
        scannerMode: 'CLI'
        configMode: 'manual'
        cliProjectKey: '*'
        cliSources: '*'

    - task: SonarQubeAnalyze@6
      inputs:
        jdkversion: 'JAVA_HOME'
        scannerPath: ' /opt/sonar-scanner/sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner'
    
    - script: |
        docker build -t $(acrLoginServer)/$(imageName):$(imageTag)-$(DATE_TAG) .
      displayName: 'Build Docker Image'

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

Thanks. Is this an on-premise build agent? If so, can you manually check if this file path (or anything like it) exists?

UUIDS aside, looking for a sonar-scanner executable/folder under /home/vmuser-uls/myagent/_work/_tasks/ would be telling.

/home/vmuser-uls/myagent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/6.3.2/sonar-scanner/bin/sonar-scanner

It might also be useful to try uninstalling and then reinstalling the SonarQube Extension for Azure DevOps.