手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu 14.04安装配置SonarQube 6.0

[日期:2017-06-12] 来源:www.jianshu.com  作者:不是个好人 [字体: ]

Ubuntu 14.04安装配置SonarQube 6.0过程记录。

1. 环境要求

mysql-server-5.6(也支持其他数据库,不过我选用的mysqlsonarqube6.0
jdk1.8
sonar-runner-2.4

2.数据库配置

mysql -u root -p
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 
mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
mysql> FLUSH PRIVILEGES;

注:在配置数据库之前一定要确保上述软件版本正确,否则会运行出错。一旦运行出错,需要删除sonar数据库,重新运行上述配置语句。

3. 环境变量

export SONAR_HOME="/home/xx/file/sonarqube-6.0"
export SONAR_RUNNER_HOME="/home/xx/file/sonar-runner-2.4"

然后将SONAR_RUNNER_HOME/bin添加到path中去

4.修改sornarqube配置

vi $SONAR_HOEME/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    
sonar.jdbc.driverClassName:com.mysql.jdbc.Driver

5.修改sonar-runner配置

vi $SONAR_RUNNER_HOME/conf/sonar-runner.properties
sonar.host.url=[http://localhost:9000](http://localhost:9000/sonar)
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

注:以上配置文件中本来就存在的,只需要去掉相应的注释符号即可。

6. 开始使用

以上运行环境都准备好了之后,即可开始运行。
在$SONAR_HOME/bin/linux-x86-64/目录下运行sonar.sh

sonar.sh start

可以通过查看$SONAR_HOME/log/sonar.log查看是否成功运行,如果看到如下日志

2016.09.05 10:31:32 INFO  ce[o.s.ce.app.CeServer] Compute Engine is up
2016.09.05 10:31:33 INFO  app[o.s.p.m.Monitor] Process[ce] is up

即成功运行。可以在浏览器中访问http://localhost:9000,如果能正常打开,说明配置正确。
注:这里我碰到一个问题,就是访问http://localhost:9000一直访问不了,后来改为访问http://localhost:9000/sonar,就能正常访问了。账户密码默认的为admin,admin。

7. 运行sonar-runner检测代码

在待检测工程目录下,直接运行sonar-runner,即开始检测。如果这里显示无法连接http://localhost:9000/,可以检查之前配置是否有误。如果出现下面日志,说明解析成功

19:01:51.759 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
19:01:51.759 INFO  - More about the report processing at http://localhost:9000/sonar/api/ce/task?id=AVb6Au95YHi3B3QHd6Kc
19:01:51.800 INFO  - Task total time: 5.674 s

根据日志中链接可直接查看检测结果。

配置Sonar、Jenkins进行持续审查 http://www.linuxidc.com/Linux/2016-08/133877.htm

sonarQube代码质量管理工具环境筹建笔记 http://www.linuxidc.com/Linux/2016-08/133878.htm

SonarQube代码质量管理平台安装与使用  http://www.linuxidc.com/Linux/2016-08/133879.htm

SonarQube升级过程记录  http://www.linuxidc.com/Linux/2016-08/133880.htm

Ubuntu 16.04下安装配置SonarQube+MySQL  http://www.linuxidc.com/Linux/2017-05/143860.htm

Fedora 21上搭建Jenkins+SonarQube的Maven项目自动化测试平台  http://www.linuxidc.com/Linux/2017-02/140780.htm

Sonar 的详细介绍请点这里
Sonar 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-06/144683.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款