Azure Devops - Sonarcloud Analysis - Could not find the pullrequest with key when creating PR in Az

General Info

  • ALM used Azure DevOps
  • CI system used Azure DevOps
  • Scanner command used when applicable (private details masked)
  • Languages of the repository: C#, JS, Typescript (Irrelevant for the issue - the problem is generic and exist in all our pipelines on over 30 projects)
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)

We are experiencing that all our PR builds fail on Sonarcloud Analysis task with the error that the PR with KEY does not exist. This happens for ALL our pipelines regardless of repo content.

It fails on the automated PR Build

SONAR PREPARE - Automated via PR Build Policy in Azure Devops.

2023-11-06T10:50:26.4781605Z ##[section]Starting: Sonarcloud Analysis Preparation
2023-11-06T10:50:26.4903006Z ==============================================================================
2023-11-06T10:50:26.4903382Z Task         : Prepare Analysis Configuration
2023-11-06T10:50:26.4903621Z Description  : Prepare SonarCloud analysis configuration
2023-11-06T10:50:26.4903923Z Version      : 1.40.2
2023-11-06T10:50:26.4904057Z Author       : sonarsource
2023-11-06T10:50:26.4904202Z Help         : Version: 1.40.2. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
2023-11-06T10:50:26.4905310Z ==============================================================================
2023-11-06T10:50:28.3498817Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:OBFUSCATED /o:OBFUSCATED
2023-11-06T10:50:28.4995555Z SonarScanner for MSBuild 5.14
2023-11-06T10:50:28.4996706Z Using the .NET Framework version of the Scanner for MSBuild
2023-11-06T10:50:28.5525805Z Pre-processing started.
2023-11-06T10:50:28.5559075Z Preparing working directories...
2023-11-06T10:50:29.5964826Z 10:50:29.583  Updating build integration targets...
2023-11-06T10:50:29.7915706Z 10:50:29.786  Fetching analysis configuration settings...
2023-11-06T10:50:30.4659004Z 10:50:30.46  Provisioning analyzer assemblies for cs...
2023-11-06T10:50:30.4669701Z 10:50:30.46  Installing required Roslyn analyzers...
2023-11-06T10:50:30.4676434Z 10:50:30.46  Processing plugin: csharp version 9.11.0.78383
2023-11-06T10:50:30.8439282Z 10:50:30.836  Processing plugin: vbnet version 9.11.0.78383
2023-11-06T10:50:31.0824676Z 10:50:31.069  Processing plugin: securitycsharpfrontend version 10.3.0.27281
2023-11-06T10:50:31.5714437Z 10:50:31.569  Provisioning analyzer assemblies for vbnet...
2023-11-06T10:50:31.5715493Z 10:50:31.569  Installing required Roslyn analyzers...
2023-11-06T10:50:31.5716735Z 10:50:31.569  Processing plugin: csharp version 9.11.0.78383
2023-11-06T10:50:31.5720886Z 10:50:31.569  Processing plugin: vbnet version 9.11.0.78383
2023-11-06T10:50:31.7540137Z 10:50:31.747  Downloading cache. Project key: OBFUSCATED, branch: main.
2023-11-06T10:50:32.3776593Z 10:50:32.372  Incremental PR analysis: 42 files out of 43 are unchanged.
2023-11-06T10:50:32.4142264Z 10:50:32.404  Pre-processing succeeded.
2023-11-06T10:50:32.4595700Z ##[section]Finishing: Sonarcloud Analysis Preparation

SONAR ANALYZE - Automated via PR Build Policy in Azure Devops.

2023-11-06T10:53:47.3333467Z ##[section]Starting: Sonarcloud Analysis
2023-11-06T10:53:47.3469932Z ==============================================================================
2023-11-06T10:53:47.3470281Z Task         : Run Code Analysis
2023-11-06T10:53:47.3470476Z Description  : Run scanner and upload the results to the SonarCloud server.
2023-11-06T10:53:47.3470876Z Version      : 1.43.2
2023-11-06T10:53:47.3470993Z Author       : sonarsource
2023-11-06T10:53:47.3471156Z Help         : Version: 1.43.2. 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.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
2023-11-06T10:53:47.3472917Z ==============================================================================
2023-11-06T10:53:47.7086952Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2023-11-06T10:53:47.7841427Z SonarScanner for MSBuild 5.14
2023-11-06T10:53:47.7842229Z Using the .NET Framework version of the Scanner for MSBuild
2023-11-06T10:53:47.8419972Z Post-processing started.
2023-11-06T10:53:48.0926039Z 10:53:48.091  10:53:48.091  WARNING: File 'C:\Users\VssAdministrator\AppData\Local\Temp\asrj5axq.osx\obj\Release\net7.0\WorkerExtensions.AssemblyInfo.cs' is not located under the base directory 'D:\a\1\s' and will not be analyzed.
2023-11-06T10:53:48.1168235Z Calling the TFS Processor executable...
2023-11-06T10:53:48.2919784Z Attempting to locate the CodeCoverage.exe tool...
2023-11-06T10:53:48.2961885Z Attempting to locate the CodeCoverage.exe tool using setup configuration...
2023-11-06T10:53:48.9482267Z Code coverage command line tool: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2023-11-06T10:53:48.9702922Z Fetching code coverage report information from TFS...
2023-11-06T10:53:48.9725220Z Attempting to locate a test results (.trx) file...
2023-11-06T10:53:49.4826784Z Looking for TRX files in: D:\a\1\TestResults
2023-11-06T10:53:49.4831291Z No test results files found
2023-11-06T10:53:50.0168387Z Did not find any binary coverage files in the expected location.
2023-11-06T10:53:50.0191424Z Falling back on locating coverage files in the agent temp directory.
2023-11-06T10:53:50.0197792Z Searching for coverage files in D:\a\_temp
2023-11-06T10:53:50.0212819Z No coverage files found in the agent temp directory.
2023-11-06T10:53:50.0213866Z Coverage report conversion completed successfully.
2023-11-06T10:53:50.0288940Z The TFS Processor has finished
2023-11-06T10:53:50.0345190Z Calling the SonarScanner CLI...
2023-11-06T10:53:57.0328272Z INFO: Scanner configuration file: D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\sonar-scanner-4.8.1.3023\bin\..\conf\sonar-scanner.properties
2023-11-06T10:53:57.0803785Z INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
2023-11-06T10:53:57.5729651Z INFO: SonarScanner 4.8.1.3023
2023-11-06T10:53:57.5730947Z INFO: Java 17.0.9 Eclipse Adoptium (64-bit)
2023-11-06T10:53:57.5731577Z INFO: Windows Server 2022 10.0 amd64
2023-11-06T10:54:04.4086611Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
2023-11-06T10:54:11.4188207Z INFO: Analyzing on SonarCloud
2023-11-06T10:54:11.4191988Z INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
2023-11-06T10:54:14.1953509Z INFO: Load global settings
2023-11-06T10:54:15.0365918Z INFO: Load global settings (done) | time=845ms
2023-11-06T10:54:15.0416151Z INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
2023-11-06T10:54:15.1296163Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
2023-11-06T10:54:15.1297869Z INFO: Loading required plugins
2023-11-06T10:54:15.1300364Z INFO: Load plugins index
2023-11-06T10:54:16.2957666Z INFO: Load plugins index (done) | time=1168ms
2023-11-06T10:54:16.2959975Z INFO: Load/download plugins
2023-11-06T10:54:18.1005402Z INFO: Load/download plugins (done) | time=1801ms
2023-11-06T10:54:19.3649708Z INFO: Loaded core extensions: developer-scanner
2023-11-06T10:54:20.0991868Z INFO: Found an active CI vendor: 'Azure DevOps'
2023-11-06T10:54:20.1152920Z INFO: Load project settings for component key: 'OBFUSCATED'
2023-11-06T10:54:20.9194207Z INFO: Load project settings for component key: 'OBFUSCATED' (done) | time=794ms
2023-11-06T10:54:20.9784198Z INFO: Process project properties
2023-11-06T10:54:20.9785246Z INFO: Execute project builders
2023-11-06T10:54:21.1583182Z INFO: Execute project builders (done) | time=187ms
2023-11-06T10:54:21.1625940Z INFO: Project key: OBFUSCATED
2023-11-06T10:54:21.1626716Z INFO: Base dir: D:\a\1\s
2023-11-06T10:54:21.1627538Z INFO: Working dir: D:\a\1\.sonarqube\out\.sonar
2023-11-06T10:54:22.0543103Z INFO: Load project branches
2023-11-06T10:54:22.8598071Z INFO: Load project branches (done) | time=810ms
2023-11-06T10:54:22.8746370Z INFO: Check ALM binding of project 'OBFUSCATED'
2023-11-06T10:54:23.9321319Z INFO: Detected project binding: BOUND
2023-11-06T10:54:23.9326056Z INFO: Check ALM binding of project 'OBFUSCATED' (done) | time=1067ms
2023-11-06T10:54:23.9366909Z INFO: Load project pull requests
2023-11-06T10:54:24.7415964Z INFO: Load project pull requests (done) | time=801ms
2023-11-06T10:54:24.7417644Z INFO: Load branch configuration
2023-11-06T10:54:25.5776231Z INFO: ------------------------------------------------------------------------
2023-11-06T10:54:25.5936544Z INFO: EXECUTION FAILURE
2023-11-06T10:54:25.5986585Z INFO: ------------------------------------------------------------------------
2023-11-06T10:54:25.6008128Z INFO: Total time: 28.739s
2023-11-06T10:54:25.6089737Z INFO: Final Memory: 10M/40M
2023-11-06T10:54:25.6091496Z INFO: ------------------------------------------------------------------------
2023-11-06T10:54:25.6146008Z ##[error]ERROR: Error during SonarScanner execution
2023-11-06T10:54:25.6154712Z ERROR: Error during SonarScanner execution
2023-11-06T10:54:25.6155826Z ##[error]ERROR: Could not find the pullrequest with key '2164'
2023-11-06T10:54:25.6157725Z ERROR: Could not find the pullrequest with key '2164'
2023-11-06T10:54:25.6160752Z ##[error]ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=OBFUSCATED&pullrequestKey=2164 : {"errors":[{"msg":"Unable to find the pullrequest with key \u00272164\u0027"}]}
2023-11-06T10:54:25.6164109Z ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=OBFUSCATED&pullrequestKey=2164 : {"errors":[{"msg":"Unable to find the pullrequest with key \u00272164\u0027"}]}
2023-11-06T10:54:25.6165920Z ##[error]ERROR:
2023-11-06T10:54:25.6166676Z ERROR: 
2023-11-06T10:54:25.9719837Z ##[error]The SonarScanner did not complete successfully
2023-11-06T10:54:25.9723163Z The SonarScanner did not complete successfully
2023-11-06T10:54:25.9726142Z ##[error]10:54:25.958  Post-processing failed. Exit code: 1
2023-11-06T10:54:25.9727840Z 10:54:25.958  Post-processing failed. Exit code: 1
2023-11-06T10:54:25.9840567Z ##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2023-11-06T10:54:25.9911231Z ##[section]Finishing: Sonarcloud Analysis

If I then - Manually, run the exact same pipeline again, same branch etc, then the pipeline succeeds.

AzureDevops-PR-Manual-Build

Below is the log output for Manual triggered build:

SONAR PREPARE - Manual trigger of the PR merge branch.

2023-11-06T11:05:21.3531540Z ##[debug]Evaluating condition for step: 'Sonarcloud Analysis Preparation'
2023-11-06T11:05:21.3534962Z ##[debug]Evaluating: and(succeeded(), eq('False', 'false'))
2023-11-06T11:05:21.3535386Z ##[debug]Evaluating and:
2023-11-06T11:05:21.3541586Z ##[debug]..Evaluating succeeded:
2023-11-06T11:05:21.3542267Z ##[debug]..=> True
2023-11-06T11:05:21.3542499Z ##[debug]..Evaluating eq:
2023-11-06T11:05:21.3543792Z ##[debug]....Evaluating String:
2023-11-06T11:05:21.3544351Z ##[debug]....=> 'False'
2023-11-06T11:05:21.3544744Z ##[debug]....Evaluating String:
2023-11-06T11:05:21.3545016Z ##[debug]....=> 'false'
2023-11-06T11:05:21.3550365Z ##[debug]..=> True
2023-11-06T11:05:21.3550839Z ##[debug]=> True
2023-11-06T11:05:21.3552287Z ##[debug]Expanded: and(True, eq('False', 'false'))
2023-11-06T11:05:21.3552694Z ##[debug]Result: True
2023-11-06T11:05:21.3553057Z ##[section]Starting: Sonarcloud Analysis Preparation
2023-11-06T11:05:21.3677942Z ==============================================================================
2023-11-06T11:05:21.3678266Z Task         : Prepare Analysis Configuration
2023-11-06T11:05:21.3678467Z Description  : Prepare SonarCloud analysis configuration
2023-11-06T11:05:21.3678731Z Version      : 1.40.2
2023-11-06T11:05:21.3678837Z Author       : sonarsource
2023-11-06T11:05:21.3678961Z Help         : Version: 1.40.2. [More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
2023-11-06T11:05:21.3679623Z ==============================================================================
2023-11-06T11:05:21.4120016Z ##[debug]Using node path: C:\agents\3.227.2\externals\node10\bin\node.exe
2023-11-06T11:05:21.7530797Z ##[debug]agent.TempDirectory=D:\a\_temp
2023-11-06T11:05:21.7554584Z ##[debug]loading inputs and endpoints
2023-11-06T11:05:21.7566422Z ##[debug]loading ENDPOINT_AUTH_OBFUSCATED
2023-11-06T11:05:21.7755940Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_OBFUSCATED_APITOKEN
2023-11-06T11:05:21.7758772Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-11-06T11:05:21.7760869Z ##[debug]loading ENDPOINT_AUTH_SCHEME_OBFUSCATED
2023-11-06T11:05:21.7762576Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-11-06T11:05:21.7764230Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-11-06T11:05:21.7766943Z ##[debug]loading INPUT_CLIPROJECTVERSION
2023-11-06T11:05:21.7768694Z ##[debug]loading INPUT_CLISOURCES
2023-11-06T11:05:21.7770390Z ##[debug]loading INPUT_CONFIGFILE
2023-11-06T11:05:21.7772050Z ##[debug]loading INPUT_CONFIGMODE
2023-11-06T11:05:21.7773679Z ##[debug]loading INPUT_EXTRAPROPERTIES
2023-11-06T11:05:21.7775292Z ##[debug]loading INPUT_ORGANIZATION
2023-11-06T11:05:21.7776885Z ##[debug]loading INPUT_PROJECTKEY
2023-11-06T11:05:21.7778515Z ##[debug]loading INPUT_PROJECTNAME
2023-11-06T11:05:21.7780117Z ##[debug]loading INPUT_PROJECTVERSION
2023-11-06T11:05:21.7781714Z ##[debug]loading INPUT_SCANNERMODE
2023-11-06T11:05:21.7783345Z ##[debug]loading INPUT_SONARCLOUD
2023-11-06T11:05:21.7790119Z ##[debug]loading SECRET_QA-APIKEY
2023-11-06T11:05:21.7792786Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-11-06T11:05:21.7802591Z ##[debug]loaded 19
2023-11-06T11:05:21.7809568Z ##[debug]Agent.ProxyUrl=undefined
2023-11-06T11:05:21.7810456Z ##[debug]Agent.CAInfo=undefined
2023-11-06T11:05:21.7811010Z ##[debug]Agent.ClientCert=undefined
2023-11-06T11:05:21.7811602Z ##[debug]Agent.SkipCertValidation=undefined
2023-11-06T11:05:22.1277131Z ##[debug]SonarCloud=OBFUSCATED
2023-11-06T11:05:22.1277979Z ##[debug]OBFUSCATED=https://sonarcloud.io/
2023-11-06T11:05:22.1285310Z ##[debug]OBFUSCATED auth param apitoken = ***
2023-11-06T11:05:22.1286374Z ##[debug]OBFUSCATED auth param username = undefined
2023-11-06T11:05:22.1287254Z ##[debug]OBFUSCATED auth param password = undefined
2023-11-06T11:05:22.1289538Z ##[debug]organization=OBFUSCATED
2023-11-06T11:05:22.1290039Z ##[debug]scannerMode=MSBuild
2023-11-06T11:05:22.1290588Z ##[debug]projectKey=OBFUSCATED
2023-11-06T11:05:22.1291351Z ##[debug]projectName=OBFUSCATED
2023-11-06T11:05:22.1291903Z ##[debug]projectVersion=1.0
2023-11-06T11:05:22.1292351Z ##[debug]organization=OBFUSCATED
2023-11-06T11:05:22.1292910Z ##[debug][SQ] API GET: '/api/server/version' with query "undefined"
2023-11-06T11:05:22.4283246Z ##[debug]Response: 200 Body: "8.0.0.49842"
2023-11-06T11:05:22.4293116Z ##[debug]System.TeamFoundationCollectionUri=https://dev.azure.com/OBFUSCATED/
2023-11-06T11:05:22.4293942Z ##[debug]System.PullRequest.PullRequestId=undefined
2023-11-06T11:05:22.4294526Z ##[debug]Build.Repository.Provider=TfsGit
2023-11-06T11:05:22.4295072Z ##[debug]Build.SourceBranch=refs/pull/2164/merge
2023-11-06T11:05:22.4299543Z ##[debug]SYSTEMVSSCONNECTION exists true
2023-11-06T11:05:22.5616289Z ##[debug]Build.Repository.Name=OBFUSCATED
2023-11-06T11:05:22.5617293Z ##[debug]System.TeamProject=Imerco - Infrastructure - Backend
2023-11-06T11:05:22.6275501Z ##[debug]Default branch of this repository is 'refs/heads/main'
2023-11-06T11:05:22.6276412Z ##[debug]Build.SourceBranch=refs/pull/2164/merge
2023-11-06T11:05:22.6277278Z ##[debug]SonarCloud or SonarQube version >= 7.2.0 detected, setting report-task.txt file to its newest location.
2023-11-06T11:05:22.6278122Z ##[debug]Agent.TempDirectory=D:\a\_temp
2023-11-06T11:05:22.6278642Z ##[debug]Build.BuildId=11199
2023-11-06T11:05:22.6281096Z ##[debug][SQ] Branch and PR parameters: {"sonar.branch.name":"refs/pull/2164/merge","sonar.scanner.metadataFilePath":"D:\\a\\_temp\\sonar\\11199\\76d6ef64-e3fc-986c-67e7-31327c4dbb63\\report-task.txt"}
2023-11-06T11:05:22.6284479Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner, 
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
2023-11-06T11:05:22.6286116Z ##[debug]set SONARQUBE_SERVER_VERSION=8.0.0
2023-11-06T11:05:22.6295201Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SERVER_VERSION;isOutput=false;issecret=false;]8.0.0
2023-11-06T11:05:22.6296254Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2023-11-06T11:05:22.6297308Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;isOutput=false;issecret=false;]MSBuild
2023-11-06T11:05:22.6298494Z ##[debug]set SONARQUBE_SCANNER_REPORTTASKFILE=D:\a\_temp\sonar\11199\76d6ef64-e3fc-986c-67e7-31327c4dbb63\report-task.txt
2023-11-06T11:05:22.6300422Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_REPORTTASKFILE;isOutput=false;issecret=false;]D:\a\_temp\sonar\11199\76d6ef64-e3fc-986c-67e7-31327c4dbb63\report-task.txt
2023-11-06T11:05:22.6301617Z ##[debug]set SONARQUBE_ENDPOINT=********
2023-11-06T11:05:22.6309671Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;isOutput=false;issecret=true;]***
2023-11-06T11:05:22.6314947Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner, 
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
2023-11-06T11:05:22.6317283Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2023-11-06T11:05:22.6320004Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;isOutput=false;issecret=false;]MSBuild
2023-11-06T11:05:22.6320944Z ##[debug]set SONARQUBE_ENDPOINT=********
2023-11-06T11:05:22.6323811Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;isOutput=false;issecret=true;]***
2023-11-06T11:05:22.6326661Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io/","sonar.token":***,"sonar.organization":"OBFUSCATED","sonar.projectKey":"OBFUSCATED","sonar.projectName":"OBFUSCATED","sonar.projectVersion":"1.0","sonar.branch.name":"refs/pull/2164/merge","sonar.scanner.metadataFilePath":"D:\\a\\_temp\\sonar\\11199\\76d6ef64-e3fc-986c-67e7-31327c4dbb63\\report-task.txt"}
2023-11-06T11:05:22.6334421Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;isOutput=false;issecret=false;]{"sonar.host.url":"https://sonarcloud.io/","sonar.token":***,"sonar.organization":"OBFUSCATED","sonar.projectKey":"OBFUSCATED","sonar.projectName":"OBFUSCATED","sonar.projectVersion":"1.0","sonar.branch.name":"refs/pull/2164/merge","sonar.scanner.metadataFilePath":"D:\\a\\_temp\\sonar\\11199\\76d6ef64-e3fc-986c-67e7-31327c4dbb63\\report-task.txt"}
2023-11-06T11:05:22.6338615Z ##[debug]Absolute path for pathSegments: D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2,classic-sonar-scanner-msbuild,SonarScanner.MSBuild.exe = D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2023-11-06T11:05:22.6341243Z ##[debug]Using classic scanner at D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2023-11-06T11:05:22.6343142Z ##[debug]set SONARQUBE_SCANNER_MSBUILD_EXE=D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2023-11-06T11:05:22.6346017Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MSBUILD_EXE;isOutput=false;issecret=false;]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2023-11-06T11:05:22.6348061Z ##[debug]which 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:05:22.6349735Z ##[debug]found: 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:05:22.6351366Z ##[debug]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: begin
2023-11-06T11:05:22.6353270Z ##[debug]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /k:OBFUSCATED
2023-11-06T11:05:22.6355171Z ##[debug]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /o:OBFUSCATED
2023-11-06T11:05:22.6356347Z ##[debug]system.debug=True
2023-11-06T11:05:22.6357445Z ##[debug]exec tool: D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2023-11-06T11:05:22.6358635Z ##[debug]arguments:
2023-11-06T11:05:22.6359191Z ##[debug]   begin
2023-11-06T11:05:22.6359793Z ##[debug]   /k:OBFUSCATED
2023-11-06T11:05:22.6360483Z ##[debug]   /o:OBFUSCATED
2023-11-06T11:05:22.6362283Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:OBFUSCATED /o:OBFUSCATED
2023-11-06T11:05:22.7350223Z SonarScanner for MSBuild 5.14
2023-11-06T11:05:22.7351127Z Using the .NET Framework version of the Scanner for MSBuild
2023-11-06T11:05:22.7852160Z Pre-processing started.
2023-11-06T11:05:22.7876343Z Preparing working directories...
2023-11-06T11:05:23.8222295Z 11:05:23.821  Updating build integration targets...
2023-11-06T11:05:24.0146447Z 11:05:24.014  Fetching analysis configuration settings...
2023-11-06T11:05:24.7334265Z 11:05:24.732  Provisioning analyzer assemblies for cs...
2023-11-06T11:05:24.7343546Z 11:05:24.734  Installing required Roslyn analyzers...
2023-11-06T11:05:24.7349544Z 11:05:24.734  Processing plugin: csharp version 9.11.0.78383
2023-11-06T11:05:25.0634035Z 11:05:25.062  Processing plugin: vbnet version 9.11.0.78383
2023-11-06T11:05:25.1949714Z 11:05:25.192  Processing plugin: securitycsharpfrontend version 10.3.0.27281
2023-11-06T11:05:25.6671226Z 11:05:25.666  Provisioning analyzer assemblies for vbnet...
2023-11-06T11:05:25.6672108Z 11:05:25.666  Installing required Roslyn analyzers...
2023-11-06T11:05:25.6672837Z 11:05:25.666  Processing plugin: csharp version 9.11.0.78383
2023-11-06T11:05:25.6675079Z 11:05:25.666  Processing plugin: vbnet version 9.11.0.78383
2023-11-06T11:05:25.6764801Z 11:05:25.676  Incremental PR analysis: Base branch parameter was not provided.
2023-11-06T11:05:25.6765909Z 11:05:25.676  Cache data is empty. A full analysis will be performed.
2023-11-06T11:05:25.7066496Z 11:05:25.701  Pre-processing succeeded.
2023-11-06T11:05:25.7151511Z ##[debug]Exit code 0 received from tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:05:25.7153610Z ##[debug]STDIO streams have closed for tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:05:25.7267271Z ##[section]Finishing: Sonarcloud Analysis Preparation

SONAR ANALYZE - Manual trigger of the PR merge branch.

2023-11-06T11:09:43.2248306Z ##[debug]Evaluating condition for step: 'Sonarcloud Analysis'
2023-11-06T11:09:43.2249517Z ##[debug]Evaluating: and(succeeded(), eq('False', 'false'))
2023-11-06T11:09:43.2249907Z ##[debug]Evaluating and:
2023-11-06T11:09:43.2250157Z ##[debug]..Evaluating succeeded:
2023-11-06T11:09:43.2250650Z ##[debug]..=> True
2023-11-06T11:09:43.2250866Z ##[debug]..Evaluating eq:
2023-11-06T11:09:43.2251120Z ##[debug]....Evaluating String:
2023-11-06T11:09:43.2251409Z ##[debug]....=> 'False'
2023-11-06T11:09:43.2251666Z ##[debug]....Evaluating String:
2023-11-06T11:09:43.2251944Z ##[debug]....=> 'false'
2023-11-06T11:09:43.2252188Z ##[debug]..=> True
2023-11-06T11:09:43.2252385Z ##[debug]=> True
2023-11-06T11:09:43.2252820Z ##[debug]Expanded: and(True, eq('False', 'false'))
2023-11-06T11:09:43.2253213Z ##[debug]Result: True
2023-11-06T11:09:43.2253511Z ##[section]Starting: Sonarcloud Analysis
2023-11-06T11:09:43.2365092Z ==============================================================================
2023-11-06T11:09:43.2365421Z Task         : Run Code Analysis
2023-11-06T11:09:43.2365624Z Description  : Run scanner and upload the results to the SonarCloud server.
2023-11-06T11:09:43.2365969Z Version      : 1.43.2
2023-11-06T11:09:43.2366070Z Author       : sonarsource
2023-11-06T11:09:43.2366202Z Help         : Version: 1.43.2. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

2023-11-06T11:10:15.4270370Z INFO: ------------- Run sensors on project

2023-11-06T11:10:15.8040598Z INFO: Importing 19 Roslyn reports
2023-11-06T11:10:15.8041685Z INFO: Found 19 MSBuild C# projects: 4 MAIN projects. 1 TEST project. 14 with no MAIN nor TEST files.
2023-11-06T11:10:15.8042485Z INFO: Sensor C# [csharp] (done) | time=485ms
2023-11-06T11:10:15.8043056Z INFO: Sensor Analysis Warnings import [csharp]
2023-11-06T11:10:15.8043688Z INFO: Sensor Analysis Warnings import [csharp] (done) | time=0ms
2023-11-06T11:10:15.8044328Z INFO: Sensor C# File Caching Sensor [csharp]
2023-11-06T11:10:15.8081367Z INFO: Sensor C# File Caching Sensor [csharp] (done) | time=15ms
2023-11-06T11:10:15.8082415Z INFO: Sensor Zero Coverage Sensor
2023-11-06T11:10:15.8593278Z INFO: Sensor Zero Coverage Sensor (done) | time=47ms
2023-11-06T11:10:15.8615919Z INFO: SCM Publisher SCM provider for this project is: git
2023-11-06T11:10:15.8687244Z INFO: SCM Publisher 1 source file to be analyzed
2023-11-06T11:10:15.8689179Z WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
2023-11-06T11:10:15.8784483Z INFO: SCM Publisher 0/1 source files have been analyzed (done) | time=0ms
2023-11-06T11:10:15.8788960Z WARN: This may lead to missing/broken features in SonarCloud
2023-11-06T11:10:15.8807254Z INFO: CPD Executor 16 files had no CPD blocks
2023-11-06T11:10:15.8807903Z INFO: CPD Executor Calculating CPD for 19 files
2023-11-06T11:10:15.9042874Z INFO: CPD Executor CPD calculation finished (done) | time=15ms
2023-11-06T11:10:15.9941242Z INFO: SCM writing changed lines
2023-11-06T11:10:15.9959086Z WARN: Could not find ref: main in refs/heads, refs/remotes/upstream or refs/remotes/origin
2023-11-06T11:10:15.9984126Z INFO: SCM writing changed lines (done) | time=0ms
2023-11-06T11:10:16.7149290Z INFO: Analysis report generated in 813ms, dir size=322 KB
2023-11-06T11:10:16.7833388Z INFO: Analysis report compressed in 78ms, zip size=81 KB
2023-11-06T11:10:17.0767466Z INFO: Analysis report uploaded in 296ms
2023-11-06T11:10:17.0818400Z INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=OBFUSCATED&branch=refs%2Fpull%2F2164%2Fmerge&resolved=false
2023-11-06T11:10:17.0820725Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2023-11-06T11:10:17.0821884Z INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AYukU31PUMOak3vLg3Y_
2023-11-06T11:10:17.1889992Z INFO: Analysis total time: 19.509 s
2023-11-06T11:10:17.1919792Z INFO: ------------------------------------------------------------------------
2023-11-06T11:10:17.1920807Z INFO: EXECUTION SUCCESS
2023-11-06T11:10:17.2098475Z INFO: ------------------------------------------------------------------------
2023-11-06T11:10:17.2100661Z INFO: Total time: 29.585s
2023-11-06T11:10:17.2771939Z INFO: Final Memory: 23M/80M
2023-11-06T11:10:17.2773741Z INFO: ------------------------------------------------------------------------
2023-11-06T11:10:17.6570817Z The SonarScanner CLI has finished
2023-11-06T11:10:17.6573115Z 11:10:17.649  Post-processing succeeded.
2023-11-06T11:10:17.6638358Z ##[debug]Exit code 0 received from tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:10:17.6643402Z ##[debug]STDIO streams have closed for tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.40.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-11-06T11:10:17.6662593Z ##[debug]set SONARQUBE_SCANNER_PARAMS="{\"sonar.host.url\":\"https://sonarcloud.io/\",\"sonar.token\":***,\"sonar.organization\":\"OBFUSCATED\",\"sonar.projectKey\":\"OBFUSCATED\",\"sonar.projectName\":\"OBFUSCATED\",\"sonar.projectVersion\":\"1.0\",\"sonar.branch.name\":\"refs/pull/2164/merge\",\"sonar.scanner.metadataFilePath\":\"D:\\\\a\\\\_temp\\\\sonar\\\\11199\\\\76d6ef64-e3fc-986c-67e7-31327c4dbb63\\\\report-task.txt\"}"
2023-11-06T11:10:17.6670437Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;isOutput=false;issecret=false;]"{\"sonar.host.url\":\"https://sonarcloud.io/\",\"sonar.token\":***,\"sonar.organization\":\"OBFUSCATED\",\"sonar.projectKey\":\"OBFUSCATED\",\"sonar.projectName\":\"OBFUSCATED\",\"sonar.projectVersion\":\"1.0\",\"sonar.branch.name\":\"refs/pull/2164/merge\",\"sonar.scanner.metadataFilePath\":\"D:\\\\a\\\\_temp\\\\sonar\\\\11199\\\\76d6ef64-e3fc-986c-67e7-31327c4dbb63\\\\report-task.txt\"}"
2023-11-06T11:10:17.6673413Z ##[debug]Reverting JAVA_HOME to its initial path.
2023-11-06T11:10:17.6674257Z ##[debug]set JAVA_HOME=C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.392-8\x64
2023-11-06T11:10:17.6675853Z ##[debug]Processed: ##vso[task.setvariable variable=JAVA_HOME;isOutput=false;issecret=false;]C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.392-8\x64
2023-11-06T11:10:17.6746199Z ##[section]Finishing: Sonarcloud Analysis

  • If I look in the project in Sonarcloud the PR does not appear (previous ones do!)
  • Our Comms Token is valid. We are able to add new projects and analyze all pipelines as long as it is NOT PR.

This issue looks to be exatly the same as
https://community.sonarsource.com/t/could-not-find-the-pullrequest-with-key-when-creating-pr-in-azure-devops/96080?u=tlogik

  • Steps to reproduce
    Assuming project exist in Sonarcloud and all connections are working between Azure Devops and Sonarcloud.
    Also assumed the analyze etc. works fine in all pipelines as long as it is NOT a pr.

Steps.

  1. In Azure Devops go to the repo in question
  2. Go to Branches and set a Build Validation on the Main branch that requires a PR to successfully build the source of the PR as a validation step before merge to main can be accepted.
  3. Setup the policy to run automatic so every update to a PR will cause a build of the PR Branch (Source)
  4. Observe the build pipeline will fail on analysis towards Sonarcloud with the error defined prior in this topic.
  • Potential workaround
    A workaround is to allow the buildpipeline not to fail on 3. party steps (in this case Sonarcloud) by setting conditions on the devops pipeline tasks you would allow to proceed even thou they failed. This will allow the buildpipeline to proceed on error and mark the pipeline with a warning. This can be acceptable. You decide.
    example: continueOnError: true

We’re facing the same issue!
Recently had to update our Java install (now 17) and sonar-scanner-cli to version 5.0.1, at the same time I reworked the pipeline to activate Sonar scan on PRs and that’s when we got these issues.

Interestingly, launching a build manually on the same branch as the PR will work fine with Sonar Cloud. It’s only when ran automatically following a PR creation/update that this step will fail with that same issue.

Azure Devops, Yaml pipeline, C++, Windows 10/11

Hello,

It looks like the Azure PAT has expired. Could you please try to generate a new one and replace it in SonarCloud?

Thanks!

Hi Marta_Sanchez_Torres

I can try creating a new PAT Token.

However can you please explain to me/us why we are able to run analysis etc. as. pr. usual?
It is only PR’s that are problematic.
I personally need to understand why some comms between Sonarcloud and Azure works and this single feature does not since i assume it all relies on the Azure PAT Token for authenticated communication.

Thanks for helping :slight_smile:

Hello Thomas,

Let me provide you with these SonarCloud documents:

I hope this helps to answer your question! Let me know if you need further information, I’ll be happy to help.