Azure Devops Pull request triggered scan has started failing

I have been demonstrating the scan on pull requests integration between Azure Devops Git Repo’s and Sonarcloud to the company ahead of wider rollout.
I have created a quality check pipeline as shown below and specified in build validation policy on the branch.

trigger:
- main

pool:
  vmImage: ubuntu-latest

stages:
  - stage:
    jobs:
    - job: RunSonarCloud
      steps:
      - checkout: self
        fetchDepth: 0
      - task: SonarCloudPrepare@1
        inputs:
          SonarCloud: 'SonarCloudServiceConnection'
          organization: 'stevechatten'
          scannerMode: 'CLI'
          configMode: manual
          cliProjectKey: stevechatten_DemoRepo10
          cliProjectName: DemoRepo10
          cliSources: './src'
      - task: SonarCloudAnalyze@1
        inputs:
          jdkversion: 'JAVA_HOME'
      - task: SonarCloudPublish@1
        inputs:
          pollingTimeoutSec: '300'

This has all been working perfectly until last night and I started getting the following error - could anyone please advise?

2023-11-28T09:05:34.1848028Z INFO: Project root configuration file: NONE
2023-11-28T09:05:34.3478008Z INFO: SonarScanner 4.8.1.3023
2023-11-28T09:05:34.3478577Z INFO: Java 11.0.21 Eclipse Adoptium (64-bit)
2023-11-28T09:05:34.3478822Z INFO: Linux 6.2.0-1016-azure amd64
2023-11-28T09:05:35.4374159Z INFO: User cache: /home/vsts/.sonar/cache
2023-11-28T09:05:37.1071757Z INFO: Analyzing on SonarCloud
2023-11-28T09:05:37.1072936Z INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
2023-11-28T09:05:37.9413611Z INFO: Load global settings
2023-11-28T09:05:38.0911628Z INFO: Load global settings (done) | time=152ms
2023-11-28T09:05:38.0957437Z INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
2023-11-28T09:05:38.1164004Z INFO: User cache: /home/vsts/.sonar/cache
2023-11-28T09:05:38.1218548Z INFO: Loading required plugins
2023-11-28T09:05:38.1224198Z INFO: Load plugins index
2023-11-28T09:05:38.2540898Z INFO: Load plugins index (done) | time=131ms
2023-11-28T09:05:38.2542693Z INFO: Load/download plugins
2023-11-28T09:05:39.2833861Z INFO: Load/download plugins (done) | time=1029ms
2023-11-28T09:05:39.4973903Z INFO: Loaded core extensions: developer-scanner
2023-11-28T09:05:39.9680856Z INFO: Found an active CI vendor: 'Azure DevOps'
2023-11-28T09:05:39.9909458Z INFO: Load project settings for component key: 'stevechatten_DemoRepo10'
2023-11-28T09:05:40.0734398Z INFO: Load project settings for component key: 'stevechatten_DemoRepo10' (done) | time=82ms
2023-11-28T09:05:40.0898765Z INFO: Process project properties
2023-11-28T09:05:40.0988011Z INFO: Execute project builders
2023-11-28T09:05:40.0996927Z INFO: Execute project builders (done) | time=1ms
2023-11-28T09:05:40.1014496Z INFO: Project key: stevechatten_DemoRepo10
2023-11-28T09:05:40.1015238Z INFO: Base dir: /home/vsts/work/1/s
2023-11-28T09:05:40.1015966Z INFO: Working dir: /home/vsts/work/1/s/.scannerwork
2023-11-28T09:05:40.2438119Z INFO: Load project branches
2023-11-28T09:05:40.3738118Z INFO: Load project branches (done) | time=130ms
2023-11-28T09:05:40.3763161Z INFO: Check ALM binding of project 'stevechatten_DemoRepo10'
2023-11-28T09:05:40.4723132Z INFO: Detected project binding: BOUND
2023-11-28T09:05:40.4732233Z INFO: Check ALM binding of project 'stevechatten_DemoRepo10' (done) | time=97ms
2023-11-28T09:05:40.4755952Z INFO: Load project pull requests
2023-11-28T09:05:40.5576003Z INFO: Load project pull requests (done) | time=82ms
2023-11-28T09:05:40.5610499Z INFO: Load branch configuration
2023-11-28T09:05:40.8787397Z INFO: ------------------------------------------------------------------------
2023-11-28T09:05:40.8792752Z INFO: EXECUTION FAILURE
2023-11-28T09:05:40.8796561Z INFO: ------------------------------------------------------------------------
2023-11-28T09:05:40.8802269Z INFO: Total time: 6.758s
2023-11-28T09:05:40.9228067Z INFO: Final Memory: 10M/37M
2023-11-28T09:05:40.9237248Z INFO: ------------------------------------------------------------------------
2023-11-28T09:05:40.9280469Z ##[error]ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key '30'
2023-11-28T09:05:40.9287511Z ERROR: Error during SonarScanner execution
2023-11-28T09:05:40.9287783Z ERROR: Could not find the pullrequest with key '30'
2023-11-28T09:05:40.9295756Z ##[error]ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=stevechatten_DemoRepo10&pullrequestKey=30 : {"errors":[{"msg":"Unable to find the pullrequest with key \u002730\u0027"}]}
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
2023-11-28T09:05:40.9296837Z ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=stevechatten_DemoRepo10&pullrequestKey=30 : {"errors":[{"msg":"Unable to find the pullrequest with key \u002730\u0027"}]}
2023-11-28T09:05:40.9297183Z ERROR: 
2023-11-28T09:05:40.9297559Z ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
2023-11-28T09:05:41.2567254Z ##[error]The process '/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.43.2/sonar-scanner/bin/sonar-scanner' failed with exit code 2
2023-11-28T09:05:41.2610472Z ##[section]Finishing: SonarCloudAnalyze

I have realized that I had an Azure Devops PAT token which expired yesterday afternoon, so this must be the issue… however I am unclear where this is used…
If I look at “Administration > General Settings > Pull Requests” I can see that a provider had not been previously specified and neither had the personal access token. As the functionality had worked before the PAT expired these mustn’t have needed to be populated so I must be looking in the wrong place.
Also, updating these values does not change the error I am getting.
Any help will be appreciated.

1 Like

Hi,

There are two places a PAT can be set: at the organization level and at the project level. Since your project-level setting is blank, this must be the one at the org level. Look under Administration → Organization settings.

 
HTH,
Ann

1 Like

Thanks Ann - that did the job!

1 Like

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