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

sonar环境搭建

时间:2017-09-05 20:56:35      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:unique   run   tor   repo   com   ssl   inno   mave   col   

本文主要在Linux环境操作,Centos7.2

1.java 1.8.0安装及环境变量配置

安装及配置参考:

http://jingyan.baidu.com/article/d5c4b52bebcb64da570dc571.html

2.mysql:5.6.36安装及配置

数据库安装采用二进制安装mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz,参考如下

http://jingyan.baidu.com/article/a378c9609eb652b3282830fd.html

修改配置文件/etc/my.cnf
default-storage-engine=INNODB
innodb_buffer_pool_size=256M
innodb_log_file_size=256M
max_allowed_packet=100M
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

本地 Mysql 创建数据库

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
本地 Mysql 创建用户并分配权限
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;

3.sonar版本:6.5

下载地址:https://www.sonarqube.org/downloads/

unzip sonarqube-6.5.zip

修改配置文件/etc/profile

export SONAR_HOME=/usr/local/sonarqube-6.5

export PATH=/jboss/apache-jmeter-2.10/bin/:$JAVA_HOME/bin://usr/local/mysql5.6.36/bin:$SONAR_HOME/bin/linux-x86-64:$MAVEN_HOME/bin:$SONAR_SCANNER_HOME/bin:/u01/ant1.9.9/bin:$PATH

修改完成后,source /etc/profile
修改conf下配置文件

3.1、修改 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&useSSL=false
3.2 启动服务

/usr/local/sonarqube-6.5/bin/linux-x86-64/目录下

./sonar.sh start

查看是否启动:netstat -pantu |grep 9000

http://localhost:9000登陆页面,默认登陆admin,密码:admin

4. 下载sonar-scanner3.0

 添加环境变量:

 export SONAR_SCANNER_HOME=/usr/local/sonar-scanner-3.0

export PATH=/jboss/apache-jmeter-2.10/bin/:$JAVA_HOME/bin://usr/local/mysql5.6.36/bin:$SONAR_HOME/bin/linux-x86-64:$MAVEN_HOME/bin:$SONAR_SCANNER_HOME/bin:/u01/ant1.9.9/bin:$PATH

5.代码管理:svn,目前把需要扫描的下载到/u01/svn/目录下
5.1.在src目录下增加sonar-project.properites

# must be unique in a given SonarQube instance
sonar.projectKey=pcWeb
# this is the name displayed in the SonarQube UI
sonar.projectName=pcWeb
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=.
sonar.java.binaries=.
sonar.language=java
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
# Additional Parameters
sonar.my.propety=value
sonar.core.codeCoveragePlugin=jacoco
sonar.jacoco.reportPath=/u01/report/workspace/sonar/target
sonar.jcoco.itReportPath=/u01/report/workspace/sonar/target
sonar.dynamicAnalysis=reuseReports


6. 执行sonar-scanner

7. 进入http://localhost:9000页面

技术分享

 

sonar环境搭建

标签:unique   run   tor   repo   com   ssl   inno   mave   col   

原文地址:http://www.cnblogs.com/jackyu126/p/7479944.html

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