1、 安装jdk,DBMS(打包机用了mysql)
2、 创建sonar user 和 database
mysql -u root -p
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;
3、下载sonar zip
wget http://dist.sonar.codehaus.org/sonarqube-5.3.zip
unzip sonarqube-5.3.zip
mv sonarqube-5.3 /usr/local
4、 修改sonar.properties
路径
/usr/local/sonar/conf/sonar.properties
修改参数
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
5、 启动sonar
sudo /usr/local/sonar/bin/linux-x86-64/sonar.sh start
6、访问 http://localhost:9000
android sonar 检测配置
build.gradle
apply plugin: "sonar-runner"
配置sonar 参数
sonarRunner {
toolVersion = "2.4"
sonarProperties {
property "sonar.projectBaseDir", "${project.rootDir}/${project.name}/"
property "sonar.host.url", "http://****:9000"
property "sonar.jdbc.url", "jdbc:mysql://****/sonar"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "***"
property "sonar.jdbc.password", "***"
property "sonar.login", "***"
property "sonar.password", "***"
property "sonar.exclusions", "**/exclude/**"
property "sonar.sources", "${project.rootDir}/${project.name}/src/main/java"
property "sonar.binaries", "$project.buildDir/intermediates/classes/"
property "sonar.projectKey", "sdk:${project.name}"
property "sonar.projectName", project.name
property "sonar.projectVersion", "1.0.0"
property "sonar.projectDescription", project.name
}
}
运行task
gradle sonarRunner
ios sonar 检测配置
条件
配置文件
把sonar-project.properties放置工程目录下
sonar.projectKey=sdk:ios
sonar.projectName=ios-sdk
sonar.projectVersion=1.0.0
sonar.language=objc
sonar.projectDescription=sdk description
sonar.sources=src
sonar.exclusions=**/exclude/**
sonar.objectivec.projects=****.xcodeproj
sonar.objectivec.appScheme=GexinSdk
sonar.sourceEncoding=UTF-8
sonar.jdbc.username=****
sonar.jdbc.password=****
sonar.login=****
sonar.password=****
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.host.url=http\://****\:9000
sonar.jdbc.url=jdbc\:mysql\://****\:3306/sonar
执行脚本
下载run-sonar.sh放置工程目录下
下载run-sonar.sh
sonar-project.properties参数
properties | Default value |
---|---|
sonar.host.url | http://localhost:9000 |
sonar.jdbc.url | jdbc:h2:tcp://localhost:9092/sonar |
sonar.jdbc.username | sonar |
sonar.jdbc.password | sonar |
sonar.projectKey | . |
sonar.projectName | . |
sonar.projectVersion | . |
sonar.language | java |
sonar.sources | . |
sonar.projectDescription | . |
sonar.binaries | . |
sonar.tests | . |
sonar.sourceEncoding | . |
sonar.importSources | . |
sonar.exclusions | . |
sonar.skippedModules | . |
sonar.includedModules | . |
sonar.branch | . |
sonar.profile | . |
sonar.skipDesign | . |
sonar.phase | . |
sonar.working.directory | . |
... | . |
网友评论