SonarQube didn't scan "master" branch

SonarQube version: 4.0.0.2929/Gradle 7.6.1
What are you trying to achieve: Scanning the “master” branch
For context: The sonarqube was running for each PR, but when the PR was merged , the master branch was never scanned.
Here’s the config for the sonar.gradle

sonarqube {
  properties {
    property "sonar.projectKey", "test-group-division-main-management"
    property "sonar.organization", "testing123"
    property "sonar.host.url", "https://sonarcloud.io"
    property "sonar.coverage.jacoco.xmlReportPaths", new File("${buildDir}/reports/jacoco/test/*")
  }
}

For the CI here’s the snippet to run the gradle

- ./gradlew sonarqube -Dorg.gradle.java.home=/usr/lib/jvm/java-17-amazon-corretto -Dsonar.login=$SONARCLOUD_KEY -Dsonar.pullrequest.branch=$head_ref -Dsonar.pullrequest.key=$pr_num -Dsonar.pullrequest.base=$base_ref -Dsonar.pullrequest.provider=github -x compileJava -x compileTestJava -x checkstyleMain -x checkstyleTest

Hey there.

It’s probably because these are being set, regardless of the branch being analyzed

What CI are you using?

Hi Colin, I’m using CodeBuild as the CI. can the sonarqube be trigger on a push / merge from the PR branch to main branch so the last analyzed of the main branch gets updated?

You will want to make sure that your build is triggered on a push/commit to master (via PR or not), and when doing so, you’ll want to make sure sonar.pullrequest.* parameters are not set.

(in pseudocode):

if PR
sonar-scanner -Dsonar.pullrequest.key…
if not PR
sonar-scanner