We’re currently using BB Cloud for a repository and have integrated the repository into a SonarCloud project. We see the Code Quality decoration on PRs, but when clicking the “See all issues on SonarCloud” link in the decoration, we get a 404 (with an error msg “Component <$PROJECT_KEY> of Pull Request <$BRANCH_NAME> does not exist”. We can see issues for the branch when going through the main SonarCloud site. Is this something we can fix on our own?
Couple of questions to clarify your situation:
- What CI service are you using to trigger the analysis?
- Do you see the name of your PR in SonarCloud web interface, or just the name of the underlying branch?
Ah, should have clarified - this is via Bitbucket Pipelines.
The error with the 404 showed the branch name, not the PR number.
I think this is the same issue as Broken SonarCloud links in Bitbucket Cloud PRs?
If so, we have a ticket open to fix this: https://jira.sonarsource.com/browse/SONAR-10977.
You can watch it to be notified when it will be fixed.
Marc, are you using the latest improvements pushed by Atlassian on Bitbucket Pipeline with regards to PR analysis?
A typical pipeline YML file should look like the following (example that you can find from the doc page):
image: node:6.9.4 clone: depth: full pipelines: default: - step: caches: - node - sonarcloud - node-scanner script: - npm install -g sonarqube-scanner - sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=bellingard-bitbucket -Dsonar.login=$SONARCLOUD_TOKEN pull-requests: '**': - step: caches: - node - sonarcloud - node-scanner script: - npm install -g sonarqube-scanner - sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=bellingard-bitbucket -Dsonar.login=$SONARCLOUD_TOKEN definitions: caches: sonarcloud: ~/.sonar/cache node-scanner: ~/.sonar/native-sonar-scanner
Not yet - we’re currently scanning based on branch regex. Reading through other forum topics, it wasn’t clear to me whether pulling in the pull-request syntax would fix this particular issue. I can test the new syntax in the next few days.
We’ve updated the pipeline config for one project to include a pull_requests section (can’t remove the branch regex sections or place a
default section for scans, since the default section matches on commits/branches that aren’t listed in a
branches: section). It looks like the Code Quality decoration fails on the PR page, but looking at the builds section of the PR page, it appears that the Code Quality testing did pass - and the SonarCloud link within the builds pop-up does point to the correct PR/branch within SonarCloud.
So you’re saying that the analysis is correctly triggered from Pipelines, but you don’t get the code quality summary on the PR page in Bitbucket Cloud?
That’s correct. However, that was due to an adblocker extension on my side. Once disabled, I do now see the code quality summary. We are getting duplicate runs of code scanning on PRs, but that’s on our end. Thanks for your help!