码迷,mamicode.com
首页 > 其他好文 > 详细

sonarqube安装

时间:2016-04-08 15:23:31      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:sonarqube安装

版本号 sonarqube4.5  sonarscanner2.5

SonarQube 安装步骤

 1. 确定 JDK 和 MySQL 已经成功安装。

 2. 下载 SonarQube 及工具 SonarQube Runner,下载地址:http://www.sonarqube.org/downloads/

 3. 解压文件,将下载的SonarQube 和SonarQube Runner 解压到指定的目录。

 4. 添加环境变量:

export SONAR_HOME=/home/huey/huey/sonar/sonarqube-5.0.1

export SONAR_RUNNER_HOME=/home/huey/huey/sonar/sonar-runner-2.4

export PATH=${SONAR_RUNNER_HOME}/bin:$PATH

 5. 

 6. 数据库(MySQL)的配置:

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER ‘sonar‘ IDENTIFIED BY ‘sonar‘;GRANT ALL ON sonar.* TO ‘sonar‘@‘%‘ IDENTIFIED BY ‘sonar‘;GRANT ALL ON sonar.* TO ‘sonar‘@‘localhost‘ IDENTIFIED BY ‘sonar‘;

FLUSH PRIVILEGES;

 7. 

在创建数据库与用户后, 修改sonar.properties 属性文件:

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=truecharacterEncoding=utf8rewriteBatchedStatements=trueuseConfigs=maxPerformance

sonar.jdbc.driverClassName=com.mysql.jdbc.Driver

8. 

根据数据库配置在 SonarQube Runner 的属性文件 sonar-runner.properties 取消对应的注释:

#Configure here general information about the environment, such as SonarQube DB details for example

#No information about specific project should appear here

 

#----- Default SonarQube server

sonar.host.url=http://localhost:9000

 

#----- PostgreSQL

sonar.jdbc.url=jdbc:postgresql://localhost/sonar

 

#----- MySQL

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=truecharacterEncoding=utf8

 

#----- Oracle

#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE

 

#----- Microsoft SQLServer

#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor

 

#----- Global database settings

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

 

#----- Default source code encoding

#sonar.sourceEncoding=UTF-8

 

 启动sonar即可 安装目录/bin/sonar start

部署php插件 

· 下载: http://docs.codehaus.org/display/SONAR/Plugin+Library/

· 注意下载的版本需要和sonarqube的版本对应

· 将下载的插件mv到sonar/extensions/plugins/ 下面

· 重启sonarqube服务

 

部署被测项目

· 将被测项目 phpcook 上传到/home/sonartest/project下面

· 在项目根目录创建文件 sonar-project.properties

· 

输入内容: 
sonar.projectKey=org.codehaus.sonar:phpcook 
sonar.projectName=PHP cook sonar test 
sonar.projectVersion=1.0 
#这里是php文件放的地方 
sonar.sources=src 
# Language 
sonar.language=php 
sonar.dynamicAnalysis=false 
# Encoding of the source files 
sonar.sourceEncoding=UTF-8

执行 sonar runner

· 等待执行结果 

查看测试结果

 

 可能会报内存溢出

解决办法

找到

exec "$JAVA_CMD" \

在后面加上

-Xms128M \

-Xmx512M \





 


sonarqube安装

标签:sonarqube安装

原文地址:http://zhaol.blog.51cto.com/4185340/1761721

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!