Could not find the pullrequest with key, pipeline failing after beeing sucsessfull

Hi

We are experiencing issiues with our Azure Devops pipelines using SonarCloudAnalyze.
We have a number of pipelines running sucsessfully, for months, but suddenly we are getting this error:

Blockquote
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]ERROR: Could not find the pullrequest with key ‘58345’
ERROR: Could not find the pullrequest with key ‘58345’
##[error]ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=[project]&pullrequestKey=58345 : {“errors”:[{“msg”:“Unable to find the pullrequest with key \u002758345\u0027”}]}

Is there any reason why a working setup suddenly gives this error?

It looks like this affects all of our pipelines, but only on Pull Requests, the analyze works fine on the main branch.

The pipelines are using:

  • task: SonarCloudPrepare@1

    • inputs:
      SonarCloud: ‘SonarCloud connection’
      organization: ‘[org]’
      scannerMode: ‘MSBuild’
      projectKey: ‘[key]_${{parameters.repositoryName}}’
      projectName: ‘${{parameters.repositoryName}}’
      extraProperties: |
      sonar.projectBaseDir=$(Build.SourcesDirectory)
  • task: SonarCloudAnalyze@1

Hey there.

Have you checked to see if the token set in SonarCloud is still valid? This can be set at the project-level as (Project-level Administration > Pull Requests > Integration with Azure DevOps Services > Personal access token), or be the global, org-level token (global Administration > Organization settings)

Hi!
Thanks for a quick response!

We are able to do the analysis on the main branch, but not in PR’s.
So the same pipeline will get the error in a PR, but will succeed if I run in on the main branch.

From the main branch analysis i just ran:

INFO: Analysis report uploaded in 408ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: SonarCloud
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=[id]

Any idea where else to look?

That’s fine – the token only gets used in the context of PR analysis, which is why it’s important to check.

Hi again,

Acording to the admin page in Sonar Cloud the token in use are valid, the account linked to the token has access to all repositories.
We are also able to verify the service connection from AzureDevops to SonarCloud just fine.
Aditionaly we have other pipelines with the same setup (same PAT, same service connection) in our organization that are able to run with out problems.

Any idea where to look next?

Have you also checked at the project-level?

Hi!
The project level was not set, so I created a new PAT and created a new PR, but it still fails.
So every setting seems to be verified OK, but the pipeline cannot find the PR.
And again, it was working before, but suddenly stopped.

I’ll reach out via PM for some private details.