Welcome 微信登录

首页 / 操作系统 / Linux / 快速搭建Sonar代码质量管理平台

快速搭建Sonar代码质量管理平台

安装

  1. 下载,直接解压http://www.sonarqube.org/downloads/
  2. 添加mysql驱动至extensionsjdbc-drivermysql
  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 MySQLsonar.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 installmvn sonar:sonar

使用Ecplise插件:

  • 安装,插件地址:http://dist.sonar-ide.codehaus.org/eclipse/ 
  • 设置插件参数,配置sonar服务器地址:
 
  • 将本地项目与sonar平台关联:
  
  • 右键检查代码质量:
配置Sonar、Jenkins进行持续审查 http://www.linuxidc.com/Linux/2016-08/133877.htmsonarQube代码质量管理工具环境筹建笔记 http://www.linuxidc.com/Linux/2016-08/133878.htmSonarQube代码质量管理平台安装与使用  http://www.linuxidc.com/Linux/2016-08/133879.htmSonar 的详细介绍:请点这里
Sonar 的下载地址:请点这里本文永久更新链接地址