歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 快速搭建Sonar代碼質量管理平台

快速搭建Sonar代碼質量管理平台

日期:2017/2/28 13:49:47   编辑:Linux教程

快速搭建Sonar代碼質量管理平台

安裝

  1. 下載,直接解壓http://www.sonarqube.org/downloads/
  2. 添加mysql驅動至\extensions\jdbc-driver\mysql\
  3. 創建mysql數據庫和用戶:10.22.10.139 db:sonar 用戶名/密碼:sonar/sonar
  4. 修改sonar.properties,注釋掉默認的數據庫配置,添加以下配置:
    #----- MySQL 5.x
    # Comment the embedded database and uncomment the following line to use MySQL
    sonar.jdbc.url=jdbc:mysql://10.22.10.139:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
  5. 啟動bin/sonar.sh start
  6. 登陸http://localhost:9000/ 用戶名/密碼:admin/admin

使用maven分析項目:

  • 在Maven的settings.xml(全局配置文件,不是項目的pom.xml)中添加以下配置:

<settings>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Example for MySQL-->
                <sonar.jdbc.url>
                  jdbc:mysql://10.22.10.139:3306/sonar?useUnicode=true&characterEncoding=utf8
                </sonar.jdbc.url>
                <sonar.jdbc.username>sonar</sonar.jdbc.username>
                <sonar.jdbc.password>sonar</sonar.jdbc.password>
 
                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://10.22.10.139:9000
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>
  • 在pom.xml所在目錄運行maven命令:
mvn clean install
mvn sonar:sonar

使用Ecplise插件:

  • 安裝,插件地址:http://dist.sonar-ide.codehaus.org/eclipse/
  • 設置插件參數,配置sonar服務器地址:

  • 將本地項目與sonar平台關聯:

  • 右鍵檢查代碼質量:

配置Sonar、Jenkins進行持續審查 http://www.linuxidc.com/Linux/2016-08/133877.htm

sonarQube代碼質量管理工具環境籌建筆記 http://www.linuxidc.com/Linux/2016-08/133878.htm

SonarQube代碼質量管理平台安裝與使用 http://www.linuxidc.com/Linux/2016-08/133879.htm

Sonar 的詳細介紹:請點這裡
Sonar 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved