0

我想将 Gradle(2.1 版)与 SonarQube(4.5.4 LTS)连接起来,但是有这个异常

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.

与这篇文章相关的应该是可能的,可能是带有相关解决方法的错误。

但是我该如何使用它呢?将 zip 解压缩到项目中并从 zip 文件中导入 build.gradle 中的行对我不起作用:((没有区别)。

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'
    }
}

提前致谢 :)

PS:Gradle 和 Sonarqube 工作正常。

4

2 回答 2

1

声纳插件已弃用

您可能希望使用新的 Sonar Runner 插件而不是这个插件。特别是,只有Sonar Runner 插件支持 Sonar 3.4 及更高版本。

仅使用Sonar Runner 插件

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>"
    }
}
于 2015-07-02T14:03:49.220 回答
1

事实上,Gradle 发行版中的两个 SonarQube 插件现在已被弃用。请参阅 Gradle 团队的以下官方消息:https ://twitter.com/gradle/status/613530568655966208 。只能使用由 SonarSource 团队直接维护的新版本:http: //docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle

于 2015-07-03T10:11:38.090 回答