How to configure SonarQube to detect new code compared with development

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube : Enterprise EditionVersion 7.9.1 (build 27448)
  • what are you trying to achieve
    For Android project, we are trying to detect new code compared to the Development branch, based on that we are planning to apply quality gates such as code coverage on new and etc

we are using following Sonar configuration on Android

sonarqube {
properties {
if (project.hasProperty(“branch”) && project.branch != “development”) {
property “”, branch
property “”, “development”

        property "sonar.projectName", *************
        property "sonar.projectVersion", branch
        property "sonar.dynamicAnalysis", "reuseReports"
        property "", "jacoco"
        property "", "**********"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.scm.disabled", "False"
        property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"

        properties["sonar.sources"] =
        properties["sonar.tests"] =

        properties[""] = files("${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes/")
        properties[""] += files("${buildDir}/tmp/kotlin-classes/debug/")
        properties[''] = files("${buildDir}/intermediates/javac/debugAndroidTest/compileDebugAndroidTestJavaWithJavac/classes/")
  • what have you tried so far to achieve this

In Sonar portal we tried 5 days, 15 days and previous_version for New Code Period.
When we tried previous_version for the first commit we are not getting New Code Difference. Then after New code is detected as the difference between the code used for the first commit we did and on the new commit code.


Welcome to the community!

8.4 introduced the ability to use a reference branch for your New Code Period. Looks like you’ll need to upgrade. Note that 8.5 is due next week.


Hey Ann,
Thanks for your response, my request is almost similar to

Looks like it is available in 7.9.1, can you please check once.

K.Raghavendra Kumar.

Hey Ann,
Any update on the same