Incremental SonarCloud scan based on pull request

Hello Team,

Looking for some assistance!

Currently, we are running SonarCloud with Amazon Web Services and BitBucket. Full scans are working fine, but they are taking a long time to complete. Thus, we have decided to implement PR-base incremental scan, where we will retrieve the changed files from the PR and perform incremental scans on them.

Based on the PR ID, we can get the source branch, destination branch, and changed files and we use the following command to scan them.

$DOTNET_ROOT/dotnet sonarscanner begin /k:“$Project” /o:“$Organization” /d:sonar.login=“$LOGIN” /d:sonar.host.url=“$HOST” /d:sonar.pullrequest.key=“$PR_DETAILS” /d:sonar.pullrequest.branch=“$SOURCE_BRANCH” /d:sonar.pullrequest.base=“$DESTINATION_BRANCH” /d:sonar.sources=“.” /d:sonar.inclusions=“$INCLUSIONS” /d:sonar.verbose=true

After the execution it is showing us that Analysis is completed on PR ID and we are able to view the PR ID in SonarCloud Pull Request section. However, we cannot see the measure or analysis code in Sonar Cloud, which says “no results”. We assume it cannot find the files or cannot scan. Could you please tell us how we can debug this issue?

Thank you in advance.

Hi,

Welcome to the community!

We’ve actually built in to PR analysis that it limits the scan (where possible) to just the files changed. So this effort is unnecessary at best.

begin is only the first step. You must also build and then call the end step. .NET analysis needs a full build. The rules run during the build.

This part is also unnecessary. The integrations will read those values automatically from the environment ( assuming the prerequisites are in place).

 
HTH,
Ann