Analyze returns: Could not find pullrequest key

Running SonarCloudAnalyze@3 in pipeline returns error:
##[error]08:01:31.281 ERROR: Could not find the pullrequest with key ‘27142’

I have checked PAT that is valid. This problem start appears when you run new functionality of automatic code scans.

Hi,

There are two places you can have a PAT: at the org level and at the project level. Can you check both places and try swapping both of them out, please?

 
Thx,
Ann

Not sure I undersood. I have checked that service connection in Azure that is using PAT is valid:

This PAT have got access to everything. Connection to Sonar is working but message that pullrequest key is missing I don’t understood. You are asking me to exchange PAT where?

As I understood for code coverage comments created by Sonar in Azure DevOps Pull Requests I need to switch off automatic analysis and left CI commands. But how to switch aumotaic analyzis, I can’t see this option?

Hi,

You’ve checked one PAT. It’s quite likely you have another one in play here.

 
Ann

I have replaced org and project PAT to fresh generated in Azure to makre sure I am using the same PAT and it doesn’t help.

Hi,

Are you sure the project you’re issuing PATs from has permissions to the repo in question?

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

sonar_pr_run_log.txt (9.9 KB)

Attaching log for all 3 steps from pull request pipeline.

Hi,

Yes, this is a permissions error.

Are you sure SonarQube Cloud itself has permissions on the repo?

 
Ann

When I run this repo as pipeline run, not pull request run, it will finish without error. What is a difference of using token/service for running normal pipeline or pull request (both use the same pipeline yaml configuration)?

Hi,

The difference goes back to those two different PATs. The one stored at project level is only used during PR analysis.

What are your org and project IDs?

 
Ann

org is pg-tr
one of the proj is PG-TR_DTMP-Library

both use the same PAT

Hi,

What scope(s) did you grant when you re-created the PAT? Also, I’ve just been reminded that branch analysis succeeding doesn’t necessarily validate the PAT. And can you verify that the user you generated the PAT with/from has more than simply branch read access on the repo? I.E. can that user open the PR in a browser?

 
Thx,
Ann