Our organization just recently started using SonarCloud. I’ve already successfully configured it for Azure DevOps projects, but having troubles with Bitbucket Cloud Pipelines.
The project repo is Node.js/Typescript app, hosted in Bitbucket. Here’s the part of the pipeline YML definition that I am using (omitting unrelated parts):
...
steps:
- step: &react_build
name: Build, Test and Analyze on SonarCloud
caches:
- node
- sonar
size: 2x
script:
...
- /bin/bash ./deployment_scripts/react_build.sh dev
- pipe: sonarsource/sonarcloud-scan:1.2.0
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
EXTRA_ARGS: '-Dsonar.organization="xxx" -Dsonar.projectKey="xxx_yyyapp" -Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/*.test.tsx,**/*.test.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info'
...
- step: &check-quality-gate-sonarcloud
name: Check the Quality Gate on SonarCloud
script:
- pipe: sonarsource/sonarcloud-quality-gate:0.1.4
pipelines:
pull-requests:
'**':
- step: *react_build
- step: *check-quality-gate-sonarcloud
branches:
develop:
- step: *react_build
- step: *check-quality-gate-sonarcloud
The pipeline executes successfully on both develop and PR branch builds.
Sonar Cloud analysis runs without any errors in logs.
The PR and target branches are correctly identified according to pipeline logs, and variables $BITBUCKET_BRANCH
and $BITBUCKET_PR_DESTINATION_BRANCH
are passed to SonarCloud.
However, after successful build and quality gate pass, I always see PR branch analysis results displayed for develop
branch, and no matter how many PRs I have gone through, I can only see develop
branch analysis in SonarCloud. This breaks PR decoration as well, as SC has analysis results for develop
branch, and PR branch results are just missing in SC.
To make it more clear, whenever I run PR build pipeline, SC data for develop
branch gets overwritten with analysis data from that PR, so I can see new code smells and bugs introduced in PR, but in SC they are displayed for develop
.
PR Provider is set to BitbucketCloud in settings, but as you can see in attached screenshot, only develop branch is available, and no dropdown with other PR branches is displayed.
I’ve probably repeated myself way too much here to explain the problem, but any help would be appreciated, as hours of Googling didn’t reveal any solutions.