0
votes

I want to connect Gradle (Version 2.1) with SonarQube (4.5.4 LTS), but there is this Exception

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':<myProject>:sonarAnalyze'.
> java.io.IOException: Server returned HTTP response code: 400 for URL:  http://localhost:9000/batch/

* Try:
Run with --debug option to get more log output.

Relating to this Post it shoud be possible, and here is maybe the Bug with the related workaround.

But how can I use it? Unpacking the zip into the Project and importing the lines from the build.gradle from the zip-file doesn't work for me :( (makes no difference).

The sonar-configuration in build.gradle:

apply plugin: "sonar"

sonar {
    server {
        url = "http://localhost:9000"
    }
    database {
        url = "jdbc:mysql://localhost:3306/sonar"
        driverClassName = "com.mysql.jdbc.Driver"
        username = "sonar"
        password = <myPassword>
    }
}

apply plugin: 'sonar-runner'

sonarRunner {
    sonarProperties {
        property 'sonar.host.url', 'http://localhost:9000'
    }
}

Thanks in advance :)

PS: Gradle and Sonarqube are working fine.

2

2 Answers

1
votes

Sonar Plugin is deprecated:

You may wish to use the new Sonar Runner Plugin instead of this plugin. In particular, only the Sonar Runner plugin supports Sonar 3.4 and higher.

Use the Sonar Runner Plugin only

apply plugin: "sonar-runner"

sonarRunner {
    sonarProperties {
        property "sonar.host.url", "http://localhost:9000"
        property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar"
        property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
        property "sonar.jdbc.username", "sonar"
        property "sonar.jdbc.password", "<myPassword>"
    }
}
1
votes

In fact the two SonarQube plugins part of the Gradle distribution are now deprecated. See the following official message from the Gradle team: https://twitter.com/gradle/status/613530568655966208. Only the new one directly maintained by the SonarSource team should be used : http://docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle