[GRADLE-3195] SonarRunner in gradle 2.2 doesn't take sonar.host.url parameter Created: 13/Nov/14  Updated: 14/Dec/14  Resolved: 09/Dec/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.3-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: René Gröschke (Inactive)
Resolution: Not A Bug Votes: 0

Known Issue Of:
2.2

 Description   

SonarRunner in gradle 2.2 doesn't seem to take sonar.host.url parameter - it always points to "[1]http://localhost:9000" regardless of either Gradle code or -D flags.

I've tried to set the sonar host via the Gradle config, the properties file, and as a flag on the command line as per the Gradle documentation.

Regardless of how we try to set it, we always get the same error message:

SonarQube Runner 2.3
Java 1.7.0_71 Oracle Corporation (64-bit)
Mac OS X 10.9.5 x86_64
INFO: Runner configuration file: NONE
INFO: Project configuration file: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/.sonar
ERROR: Sonar server '[2]http://localhost:9000' can not be reached

Our Sonar server is on version 3.7.1 of SonarCube.

This worked with Gradle 2.1.

It looks like none of the properties from the Gradle config are being utilized.

I've tried setting the sonarRunner to various older versions without success.

Here's our config section:
sonarRunner {
String SONAR_PROJ_NAME = System.getenv('GO_PIPELINE_NAME') ?: "das.webapp"
sonarProperties {
property "sonar.host.url", "[3]http://sonar.xxxx.net:8020"
property "sonar.jdbc.url", "jdbc:mysql://sonar.xxxx.net:3306/sonar"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "sonar"
property "sonar.jdbc.password", "sonar"
property "sonar.dynamicAnalysis", "reuseReports"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.jacoco.reportPath", "${buildDir}/coverage-results/jacoco.exec"
property "sonar.projectKey", "${SONAR_PROJ_NAME}"
property "sonar.projectName", "${SONAR_PROJ_NAME}"
property "sonar.description", "Ecommerce web application"
}
}

Any ideas? This is preventing us from upgrading to 2.2.
----------------------------------------------------------------------------------------
[1] http://localhost:9000
[2] http://localhost:9000
[3] http://sonar.xxxx.net:8020



 Comments   
Comment by Gradle Forums [ 13/Nov/14 ]

Hi Doug,

If you run the build with `-i`, the Sonar Runner task will log all of its properties before executing. What value do you see for the host in that property list?

Comment by Gradle Forums [ 13/Nov/14 ]

Hi Doug,

see my comment on this thread: [1]http://forums.gradle.org/gradle/topic...

You probably run into the same problem, that the sonar runner is forking, so you need to make sure you pass system properties and system environment down to the child process.

we do something like this:

sonarRunner {
forkOptions

{ // copy environment to child process. environment = System.getenv() }

}

----------------------------------------------------------------------------------------
[1] http://forums.gradle.org/gradle/topics/sonar_runner_gradle_task_is_not_compatible_with_sonar_4_4

Comment by Gradle Forums [ 13/Nov/14 ]

Here's the output wit

:test (Thread[Daemon worker,5,main]) completed. Took 15.573 secs.
:sonarRunner (Thread[Daemon worker,5,main]) started.
:sonarRunner
Executing task ':sonarRunner' (up-to-date check took 0.001 secs) due to:
Task has not declared any outputs.
Executing Sonar Runner with properties:
[sonar.projectName: das.webapp, sonar.projectDescription: DAS webapp, sonar.projectVersion: 1.5, sonar.projectBaseDir: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration, sonar.dynamicAnalysis: reuseReports, sonar.projectKey: das.webapp, sonar.environment.information.key: Gradle, sonar.environment.information.version: 2.2, sonar.working.directory: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/sonar, sonar.java.source: 1.7, sonar.java.target: 1.7, sonar.sources: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/main/resources,/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/main/groovy,/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/main/java, sonar.tests: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/test/resources,/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/test/groovy,/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/src/test/java, sonar.binaries: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/classes/main,/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/resources/main, sonar.libraries: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.j...... many jars removed
s/Home/jre/lib/rt.jar, sonar.surefire.reportsPath: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/test-results, sonar.junit.reportsPath: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/test-results, sonar.host.url: [1]http://10.216.216.249:8020, sonar.jdbc.url: jdbc:mysql://10.216.216.249:3306/sonar, sonar.jdbc.driverClassName: com.mysql.jdbc.Driver, sonar.jdbc.username: sonar, sonar.jdbc.password: sonar, sonar.java.coveragePlugin: jacoco, sonar.jacoco.reportPath: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/coverage-results/jacoco.exec, sonar.description: Ecommerce web application, sonar.exclusions: */excel/,/WorkspaceSummaryDto,/WorkspaceSummaryProcess,/SaveOrCopyWorkspaceProcess,/AssortmentProcess,/AddProductProcess,/EditedOfferingFilterProductsProcess,/CartProcess,/AssortmentUtils,/AssortmentMigrateAV,/CpdProductToDasProductMapper,*/SyncDefaultAssortmentProcess]
Starting process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java''. Working directory: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration Command: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java -Dproject.home=/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration -Dproject.settings=/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/tmp/sonarRunner/sonar-project.properties -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /Users/Shared/Development/NikeBuild/gradleHome/caches/modules-2/files-2.1/org.codehaus.sonar.runner/sonar-runner-dist/2.3/48e39e521b2888a5ab775f9220666597850562/sonar-runner-dist-2.3.jar org.sonar.runner.Main
Successfully started process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java''
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
SonarQube Runner 2.3
Java 1.7.0_71 Oracle Corporation (64-bit)
Mac OS X 10.9.5 x86_64
INFO: Runner configuration file: NONE
INFO: Project configuration file: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/.sonar
ERROR: Sonar server '[2]http://localhost:9000' can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.038s
Final Memory: 3M/245M
ERROR: Error during Sonar runner execution
INFO: ------------------------------------------------------------------------
ERROR: java.net.ConnectException: Connection refused
ERROR: Caused by: Connection refused
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
:sonarRunner FAILED
:sonarRunner (Thread[Daemon worker,5,main]) completed. Took 0.198 secs.

FAILURE: Build failed with an exception.

You can see the host server is listed properly.
----------------------------------------------------------------------------------------
[1] http://10.216.216.249:8020
[2] http://localhost:9000

Comment by Gradle Forums [ 13/Nov/14 ]

Tried that, didn't work...

Comment by Gradle Forums [ 13/Nov/14 ]

I can also see that in the build/tmp/sonarRunner/sonar-project.properties the settings are right, too (many lines deleted for clarity):

#Thu Nov 13 14:02:45 PST 2014
sonar.environment.information.version=2.2
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.host.url=http\://10.216.216.249\:8020
sonar.java.source=1.7
sonar.java.coveragePlugin=jacoco
sonar.projectDescription=DAS webapp
sonar.projectVersion=1.5
sonar.java.target=1.7
sonar.surefire.reportsPath=/Users/Shared/Development/NikeBuild/nikeDev/das/branches/merge_avintegration/build/test-results
sonar.environment.information.key=Gradle
sonar.description=Ecommerce web application
sonar.projectName=das.webapp
sonar.jdbc.url=jdbc\:mysql\://10.216.216.249\:3306/sonar
sonar.projectBaseDir=/Users/Shared/Development/NikeBuild/nikeDev/das/branches/merge_avintegration

Comment by Gradle Forums [ 13/Nov/14 ]

Noticing that the line

sonar.environment.information.version=2.2

shows 2.2, I set the version number to 2.2 as well, same result as the default of 2.3

Comment by René Gröschke (Inactive) [ 09/Dec/14 ]

we now throw a warning to inform user of misleading sonar-runner behaviour

Generated at Wed Jun 30 12:42:29 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.