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 \





 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章