Settings set via build gradle not reflected in Sonarqube UI

Configured SonarQube properties in gradle.properties files for my spring boot project and SonarQube analysis is working fine(able to verify in portal). But when it tried to add some more property in build.gradle, it is not reflecting in sonar portal .

For exmaple in build.gradle added these sonar property , which is not reflecting in sonar portal–>

     plugins {
        id 'java'
        id 'org.springframework.boot' version '2.2.7.RELEASE'
        id 'gradle-boost' version '2.1.0'
        id 'maven-publish'
        id 'jacoco'
        id 'org.sonarqube' version '2.7'
    }
    sonarqube {
        properties {
            property "sonar.projectName", "MyprojectName"
        property "sonar.projectDescription", "MyprojectDescription"
        }
    }

Properties in gradle.properties file

    # Sonar Configuration
    systemProp.sonar.projectKey=com.acc.bt.radar:vom
    systemProp.sonar.host.url=http://localhost:9000
    systemProp.sonar.login=515110c2760f20dadsdsa123d23434f6

Hi,

It’s not clear to me which properties aren’t working.

That said, project key isn’t something you should set in a global file; that should only be set at the project level or even on the analysis command line.

 
Ann

I tired by setting all properties in build.gradle (file in root folder) which did’t worked.

When i moved all the properties setting to gradle.properties file it started working.

  1. Do we have any rule like some properties should be set only via gradle.properties or command line but not in build gradle. ?
  2. To be more specific the value “MyprojectName” in ["property “sonar.projectName”, “MyprojectName” ] build.gradle sonnar setting is not reflected in Sonar UI(version:sonarqube-8.3.1.34397). Default project name value is displayed in UI.

Hi,

I’m not aware of any rules for Gradle or any of the other scanners about what can’t be set in the global file. Only what shouldn’t.

 
Ann

Alright. I am going with this sonar docs and it works.

But its still grey area ,why if we move the sonar settings from gradle.properties to build.gradle it does’t worked?.

Thanks Ann ,much appreciated for your time.

Hi,

I really think that’s going to end up being a Gradle thing & I don’t have the background there to help.

 
:woman_shrugging:
Ann