【问题标题】:Configuring Sonar plugin for Jenkins为 Jenkins 配置声纳插件
【发布时间】:2014-05-27 18:12:29
【问题描述】:

我对在Jenkins 上配置Sonar 插件 感到有些困惑。我去了 Manage Jenkins -> Configure System 并添加了Sonar。我对在Sonar 部分的Database URL 中添加什么感到困惑。

我放了

jdbc:mysql://10.4.1.206/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

10.4.1.206 是我要连接的节点。

但是,端口是3306。

我应该放吗

jdbc:mysql://10.4.1.206:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true or just leave it like before?

另外,由于我使用的是MySQL,我是否需要将com.mysql.jdbc.Driver 放在Driver 部分?如果我使用嵌入式默认驱动程序,它会说将其留空。

请原谅我;这是我第一次篡改JenkinsSonar

【问题讨论】:

    标签: jenkins sonarqube


    【解决方案1】:

    如果您已将 Sonar 配置为使用 MySQL,则需要同时提供 URL 和驱动程序。声纳的默认嵌入式数据库是 Derby - 您将在下面找到默认声纳配置的示例:

    # Comment the 3 following lines to deactivate the default embedded database
    sonar.jdbc.url:                            jdbc:derby://localhost:1527/sonar;create=true
    sonar.jdbc.driverClassName:                org.apache.derby.jdbc.ClientDriver
    sonar.jdbc.validationQuery:                values(1)
    

    因此,如果您已将 Sonar 配置为使用 MySQL,而我只能假设您已配置,那么让我们分析一下配置本身:

    您需要显式声明的驱动程序是com.mysql.jdbc.Driver

    您的 URL 字符串对我来说看起来不错。根据 MySQL Connect 规范:

    MySQL Connector/J 的 JDBC URL 格式如下,方括号 ([, ]) 中的项目是可选的:

    jdbc:mysql://[host][,failoverhost...][:port]/[database]  » 
    [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
    

    如果未指定主机名,则默认为 127.0.0.1。如果未指定端口,则默认为 3306,即 MySQL 服务器的默认端口号。

    jdbc:mysql://[host:port],[host:port].../[database] »
    [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
    

    在我当前的设置中,连接如下:

    jdbc:mysql://localhost:3306/radical_sonar?useUnicode=true&characterEncoding=utf8
    

    为了避免混淆,我倾向于明确使用端口号,而不是其他任何东西 - 我们确实有一个测试 MariaDB 安装在不同的端口上运行...

    【讨论】:

      【解决方案2】:

      Manage Jenkins > Configure System 中,您的 Sonar-Settings 应如下所示:

      数据库 URL 应该是:

      jdbc:mysql://10.4.1.206:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
      

      司机应该是:

      com.mysql.jdbc.Driver
      

      如果您需要更多信息,您可能还想查看您的 "sonarqube/conf/sonar.properties" 文件和以下文档链接

      http://docs.codehaus.org/display/SONAR/Configuring+SonarQube+Jenkins+Plugin

      祝你的配置好运!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-22
        • 2013-05-15
        • 2012-06-08
        • 2013-05-29
        • 2019-10-09
        • 2016-05-11
        • 2015-08-08
        • 2011-07-31
        相关资源
        最近更新 更多