SonarQube 平台
1.下载包,安装启动
2.在sonar.properties 配置mysql数据库的
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
3。创建数据库 CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
4.创建用户分配权限:
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON *.* TO 'sonar'@'%' IDENTIFIED BY 'sonar' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar' WITH GRANT OPTION;
FLUSH PRIVILEGES;
在数据库表执行上面
5.需要有java环境配置
sonarQube 默认端口在9000
如果java 需要依赖maven 需要配置maven 环境
然后在
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.login=047cf5b2c769ff9e0a3291521dbb8db2d620c031
安卓代码审查
在根目录gradle:
buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5" } } plugins { # 添加插件信息 id "org.sonarqube" version "2.6-rc1" } apply plugin: "org.sonarqube"
jenkis:
安卓
在构建处选择Execute SonarQube Scanner中配置如下
sonar.projectKey=android
sonar.projectName=android
sonar.projectVersion=1.0
sonar.language=java
sonar.java.binaries=/var/lib/jenkins/workspace/android/yaok
sonar.sources=/var/lib/jenkins/workspace/android/yaok/src
sprng boot 后端配置
构建环境
Prepare SonarQube Scanner environment
构建:
execute sonaqube scannar 配置
sonar.projectKey=testmvndemo
sonar.projectName=testmvndemo
sonar.projectVersion=1.1
sonar.sources=.
sonar.java.binaries=C:\\Program Files (x86)\\Jenkins\\liwanlei\\liwanlei\\src\\main\\java\\com\\example\\sell\\demo