2019独角兽企业重金招聘Python工程师标准>>>
参考文档:http://blog.csdn.net/kefengwang/article/details/54377055
一.下载:wget https://fossies.org/linux/misc/sonarqube-7.0.zip
二.配置sonar.properties
## sudo vim /opt/sonarqube-6.2/conf/sonar.properties
sonar.web.javaOpts=-server -Xms256m -Xmx768m -XX:+HeapDumpOnOutOfMemoryError
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
## 下面设定访问网址为 http://centos:9000/sonar
sonar.web.host=172.16.27.46
sonar.web.port=7070
sonar.web.context=/sonar
sonar.search.javaAdditionalOpts=-Dbootstrap.system_call_filter=false
三.安装插件(注意,如果插件在下载过程失败,需要先rm -rf 插件名,否则会重启失败)
sudo wget https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-1.13/sonar-l10n-zh-plugin-1.13.jar (汉化版)
sudo wget https://github.com/SonarQubeCommunity/sonar-findbugs/releases/download/3.4.4/sonar-findbugs-plugin-3.4.4.jar (findbugs)
sudo wget https://github.com/SonarQubeCommunity/sonar-checkstyle/releases/download/2.4/sonar-checkstyle-plugin-2.4.jar (checkstyle)
sudo wget https://github.com/SonarQubeCommunity/sonar-pmd/releases/download/2.6/sonar-pmd-plugin-2.6.jar (pmd)
sudo wget https://github.com/SonarQubeCommunity/sonar-sonargraph/releases/download/sonar-sonargraph-plugin-3.5/sonar-sonargraph-plugin-3.5.jar (sonargraph)
安装插件之后重启服务
./sonar.sh restart
四.访问地址:
http://172.16.27.46:7070/sonar admin/admin
进入:Administration(配置) / Security(权限) / User(用户),找到用户 admin,点击 “Tokens” 一列;
弹出界面里:输入 TokenName=”admin”, 点击 “Generate”, 生成 “f041b74aab3959767ae0e8584c632033b6cc9a19”
五.设置外部权限:
token:f041b74aab3959767ae0e8584c632033b6cc9a19
六.jenkens设置sonar插件
1.配置升级站点的url
打开插件管理的“高级”选项,在升级站点填写 ,然后重启
http://mirror.xmission.com/jenkins/updates/update-center.json
2.下载sonar插件
3.设置Sonar插件在jenkins(系统管理 / 系统设置/Quality Gates - Sonarqube )
注意:
1.需要添加数据库
create database sonar;
2.由于es不能再root下启动,所以我们要换用户启动sonar
报错:
需要换其他用户启动,因为需要es插件
3.mysql版本过低
当前mysql版本
当前Sonar需要mysql5.6以上的版本
4.findbugs报错:(Fail to load plugin Findbugs [findbugs] Caused by: java.lang.NoClassDefFoundError: org/sonar/api/web/CodeColorizerFormat)