Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Externalize the sonar configuration properties to gradle.properties file in user home

I want to Externalize the sonar configuration properties from build.gradle file to gradle.properties file.

for example, apply plugin: 'sonar-runner'

sonarRunner

sonarProperties

                property "sonar.java.coveragePlugin", "jacoco" 
                property "sonar.host.url", "http://10.42.58.229:9000/"
                property "sonar.jdbc.url", "jdbc:mysql://10.42.58.229:3306/sonar"
                property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"

I want to pass the property values from gradle.properties file, which is present in user home.

like image 871
user3769842 Avatar asked Feb 10 '23 20:02

user3769842


1 Answers

This is possible but the trick is that you have to use system properties (using systemProp prefix):

systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.jdbc.url=jdbc:postgresql://localhost/sonar
systemProp.sonar.jdbc.username=sonar
systemProp.sonar.jdbc.password=sonar
systemProp.sonar.login=admin
systemProp.sonar.password=admin

See: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle#AnalyzingwithSonarQubeScannerforGradle-Globalconfigurationsettings

This should work with the old 'sonar-runner' plugin but feel free to give a try to new 'org.sonarqube' plugin: https://plugins.gradle.org/plugin/org.sonarqube

like image 129
Julien H. - SonarSource Team Avatar answered Feb 15 '23 09:02

Julien H. - SonarSource Team