ERROR: Could not find the pullrequest with key

  • ALM used Bitbucket Cloud
  • CI system used Bitbucket Cloud
  • Scanner command: sonarsource/sonarcloud-scan:1.4.0
  • Languages of the repository: Typesript
  • Error observed
NFO: Base dir: /opt/atlassian/pipelines/agent/build
INFO: Working dir: /opt/atlassian/pipelines/agent/build/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=547ms
INFO: Check ALM binding of project '*****'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project '*****' (done) | time=532ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=562ms
INFO: Load branch configuration
INFO: Detected analysis for pull request '122' targeting 'master'
INFO: Auto-configuring pull request 122
  • it happens errors out when triggered by PR.
  • it always works when pipeline is run manually
  • we have several other projects that work fine.

Hey there.

This typically (although not always) happens when the repository that the SonarCloud project is bound to isn’t the repository where the pull request is raised.

If you click on the Bitbucket icon on your project overview, are you taken to the repository with Pull Request #122?

Thank you for quick reply. Yes the icon takes me to the right repo.

Thanks. I’ve flagged this thread for some expert attention.

Greetings Jan,
This most likely feels like the pull request may have been closed before the analysis was run. Could you double-check the PR exists?

If this is not the case though would you be willing to share the bitbucket-pipelines.yml configuration for sonarcloud and also provide more of the log around the error (e.g. the line from the title is missing from the shared log output)?

In our sample project for nodejs (which would cover a typescript project) the bitbucket-pipelines.yml contains a section to be triggered for pull-requests that you may be missing:

    - step: *build-test-sonarcloud
      - step: *build-test-sonarcloud

without this configuration, you won’t see Pull Requests getting populated in SonarCloud, only as branches.
Screen Shot 2022-09-19 at 14.21.32

You also mentioned it works when you run the pipeline manually, this might be because it is running against the branch and not the pull request.

Let me know if this helps clarify anything.


1 Like

Thank you for replying.
The issue fixed itself about 6 days ago.
the pipelines since then all work


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