Linux环境安装SonarQube,windows使用SonarQube Runner完整实例
来源:互联网 发布:js中alert输出变量 编辑:程序博客网 时间:2024/06/01 07:46
SonarQube简介
Sonar 是一个用于代码质量管理的开放平台。
保持我一贯的风格,废话不多说,直接实践。
准备:
- JDK
- sonarqube 官方地址:http://www.sonarqube.org/downloads/
或者 http://download.csdn.net/download/yy756127197/10039432 - SonarQube+Scanner 地址:http://download.csdn.net/download/kgd4409/9846230
- 数据库(mysql的话版本至少5.5以上)
一 .安装篇
下载地址:准备2
1.将zip解压到一个目录下
cd /var/srvbot/unzip sonarqube-5.6.7.zip
2.配置环境变量
vi /etc/profile
添加
SONAR_HOME=/var/srvbot/export SONAR_HOME
使配置生效
source /etc/profile
3.配置sonar.properties
vi /var/srvbot/sonarqube-5.6.7/conf/sonar.properties
添加
sonar.jdbc.url=jdbc:postgresql://10.20.123.77:7443/testsonar.jdbc.username=testdatasonar.jdbc.password=hero1234sonar.sorceEncoding=UTF-8sonar.login=adminsonar.password=admin
4.汉化
汉化包地址:http://download.csdn.net/download/yy756127197/10039444
其中sonar-l10n-zh-plugin-1.11.jar 是汉化包
将下载下来的jar包扔到sonarqube-5.6.7\extensions\plugins 目录下
4.启动服务
cd /var/srvbot/sonarqube-5.6.7/bin/linux-x86-64./sonar.sh start
查看启动日志
tail -f /var/srvbot/sonarqube-5.6.7/logs/sonar.log
其他命令(启动,重启,停止)
./sonar.sh start 启动服务 ./sonar.sh stop 停止服务 ./sonar.sh restart 重启服务
完成以上几步之后打开浏览器 你的主机ip:9000 就可以看到WEB界面了
登陆账号:admin
密码:admin
二 .安装篇2
实用工具SonarQube Runner来扫描你的代码
我的SonarQube 服务部署在在LINUX机器,SonarQube Runner部署在本地WINDOWS机器,方便使用。
下载地址:http://download.csdn.net/download/kgd4409/9846230
1.安装SonarQube Runner
把下载下来的sonar-scanner-2.6.1.zip解压到任意目录下
2.修改配置文件
D:\technology\sonar-scanner-2.6.1\conf\sonar-scanner.properties
添加
sonar.jdbc.url=jdbc:postgresql://10.20.123.77:7443/testsonar.jdbc.username=testdatasonar.jdbc.password=hero1234sonar.sorceEncoding=UTF-8sonar.login=adminsonar.password=admin
如果测试项目与服务器不在同一台机器,则需要添加服务器的IP
sonar.host.url=http://10.20.22.77:9000
3.配置环境变量
添加
SONAR_RUNNER_HOME=D:\technology\sonar-scanner-2.6.1
修改
PATH 添加 %SONAR_RUNNER_HOME%\bin;
4 测试
sonar-runner -version
出现如下信息,表示成功
三.使用篇
下面我们要正式测试啦
1.打开项目根路径
创建sonar-project.properties文件
2.编写sonar-project.properties
# must be unique in a given SonarQube instancesonar.projectKey=itil:change# this is the name displayed in the SonarQube UIsonar.projectName=changesonar.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=src# Encoding of the source code. Default is default system encoding#sonar.sourceEncoding=UTF-8
解释:
sonar.projectKey:SonarQube唯一标识
sonar.projectName:项目名称
sonar.sources:源文件所在路径
3.启动
在cmd进入项目所在的根目录,输入命令:sonar-runner
sonar-runner
扫描完成会出现如下图:
4.进入SonarQube WEB界面
OK,非常完美,把你项目中的BUG,重复代码等等全部列出来了。至于怎么玩,自己研究研究吧、
- Linux环境安装SonarQube,windows使用SonarQube Runner完整实例
- 【Linux运维入门】Linux环境安装SonarQube和SonarQube Runner
- Windows 安装配置sonarqube
- Linux安装SonarQube
- Linux 安装SonarQube
- SonarQube安装及使用
- SonarQube 安装使用
- SonarQube 安装配置使用
- sonarqube安装使用
- SonarQube 安装和使用
- Windows下SonarQube的安装
- SonarQube+Sonar-runner+Jacoco+Gradle搭建代码质量检测环境
- 安装SonarQube
- SonarQube 安装
- SonarQube
- SonarQube
- sonarqube
- SonarQube Scanner 安装使用文档
- Android Xrecyclervie,TabLayout+Fragment,综合
- cmd 切换管理员
- UVALive 7662 Perfect Matchings
- Python的web服务开发环境搭建过程
- spark on hive 写入hdfs
- Linux环境安装SonarQube,windows使用SonarQube Runner完整实例
- jrebel、JavaRebel
- qsort
- Tablayout
- linux操作系统下部署Javaweb项目教程
- 实验报告三
- MySQL索引数据结构
- egret 获取,本周,上周,本月,下月,本季,上季,今天,昨天,明天,开始时间和结束时间
- vncviewer退出全屏