版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chunlongyuan/article/details/79243105
Java需要安装不低于1.8的版本
mysql增加名为
sonar
的数据库,增加用户sonarqube@sonarqube
mysql> CREATE DATABASE sonar;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE USER 'sonarqube'@'%' IDENTIFIED BY 'sonarqube';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL ON *.*TO 'sonarqube'@'%';
Query OK, 0 rows affected (0.00 sec)
将SonarQube解压后修改配置文件的数据库配置和用户配置
[root@localhost pig]# vim sonarqube-6.4/conf/sonar.properties
# 配置数据库用户名和密码
sonar.jdbc.username=sonarqube
sonar.jdbc.password=sonarqube
# 打开下面这行的注释
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.web.port=9000
启动SonarQube后访问
http://ip:9000
[root@localhost pig]# cd sonarqube-6.4/bin/linux-x86-64/
[root@localhost linux-x86-64]# ./sonar.sh start
安装中文插件等
管理员区域里搜索 chinese Pack 插件,安装并重启
SonarQube Scanner 配置文件
# vim sonar-scanner/conf/sonar-scanner.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
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
sonar.scm.disabled=true
sonar-project.properties
这个我就不写了
执行
sonar-scanner
如果执行时内存不够用则修改下配置
vim /usr/local/sonarqube/sonar-scanner/bin/sonar-scanner
exec "$java_cmd" \
-Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \
$SONAR_SCANNER_DEBUG_OPTS \
-classpath "$jar_file" \
-Dscanner.home="$sonar_scanner_home" \
-Dproject.home="$project_home" \
-Xms256m \
-Xmx1024m \
org.sonarsource.scanner.cli.Main "$@"
问题汇总
- Failed to upload report - 500: An error has occurred
这是为mysql配置问题
需要修改mysql配置
[mysqld]
max_allowed_packet = 32M