# SonarRunner in gradle 2.2 doesn't take sonar.host.url parameter

**URL:** <https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441>\
**Category:** Old Forum Archive\
**Created:** [November 12, 2014, 6:14pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441 "2014-11-12T18:14:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 12, 2014, 6:14pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/1 "2014-11-12T18:14:00Z")

</div>

SonarRunner in gradle 2.2 doesn’t seem to take sonar.host.url parameter - it always points to “[http://localhost:9000](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 ‘[http://localhost:9000](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”,

“[http://sonar.xxxx.net:8020](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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [November 13, 2014, 2:27am UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/2 "2014-11-13T02:27:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Oliver\_Trosien](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@Oliver\_Trosien](https://discuss.gradle.org/u/Oliver_Trosien)\
**Post date:** [November 13, 2014, 9:24pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/3 "2014-11-13T21:24:00Z")

</div>

Hi Doug,

see my comment on this thread: [http://forums.gradle.org/gradle/topics/sonar\_runner\_gradle\_task\_is\_not\_compatible\_with\_sonar\_4\_4](http://forums.gradle.org/gradle/topics/sonar_runner_gradle_task_is_not_compatible_with_sonar_4_4)

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:

```gradle
sonarRunner {
        forkOptions {
            // copy environment to child process.
            environment = System.getenv()
      }
   }

```

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 13, 2014, 10:03pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/4 "2014-11-13T22:03:00Z")

</div>

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: [http://10.216.216.249:8020](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 ‘[http://localhost:9000](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.

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 13, 2014, 10:03pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/5 "2014-11-13T22:03:00Z")

</div>

Tried that, didn’t work…

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 13, 2014, 10:07pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/6 "2014-11-13T22:07:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 13, 2014, 10:10pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/7 "2014-11-13T22:10:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [November 13, 2014, 10:26pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/8 "2014-11-13T22:26:00Z")

</div>

Ok, so this tells me that we are passing what we think we are passing to Sonar but that it needs the host to be set in some other way. I’ve raised GRADLE-3195 for this.

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [November 14, 2014, 10:43pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/9 "2014-11-14T22:43:00Z")

</div>

Thanks, it looked like I was doing everything right 🙂

---

<div class="post-metadata">

**Author:** ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)\
**Post date:** [December 4, 2014, 11:52am UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/10 "2014-12-04T11:52:00Z")

</div>

Hey Douglas, I tried to reproduce the issue and I think it is not really a bug in gradle. It seems the sonar-runner automatically picks up properties from a sonar-project.properties file if it finds one in the working directory (which is the project directory when using gradles sonarRunner). From your logs you can see that gradle passes the project configuration file explicitly:

```
-Dproject.settings=/Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/build/tmp/sonarRunner/sonar-project.properties
```

But it seems the properties file in the project directory wins over the generated file:

```
INFO: Project configuration file: /Users/Shared/Development/NikeBuild/nikeDev/das/branches/avintegration/sonar-project.properties
```

Is there a reason for having this sonar-project.properties in your project directory?

The property “sonar.environment.information.version” is usually used to pass further information about the environment where the sonar analysis took place. In gradle we just set the gradle version there. This could be misleading as the sonar runner currently operates in the same version range (2.2)

If you can confirm my findings, I would like to mark the issue as “not a bug”.

cheers, René

---

<div class="post-metadata">

**Author:** ![douglas\_bullard](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@douglas\_bullard](https://discuss.gradle.org/u/douglas_bullard)\
**Post date:** [December 5, 2014, 10:27pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/11 "2014-12-05T22:27:00Z")

</div>

that was an old config file left over from the previous version of the sonar plugin - removing it fixed the problem.

Thanks!

---

<div class="post-metadata">

**Author:** ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)\
**Post date:** [December 5, 2014, 10:46pm UTC](https://discuss.gradle.org/t/sonarrunner-in-gradle-2-2-doesnt-take-sonar-host-url-parameter/2441/12 "2014-12-05T22:46:00Z")

</div>

Excellent,  
thanks for letting us know.  
cheers,  
René
