1.阅读SonarQube更新日志:
http://docs.codehaus.org/display/SONAR/Upgrading#Upgrading-ReleaseUpgradeNotes
2.停止SonarQube服务:
bin/<SYSTEM>/sonar stop
3.下载新版本的SonarQube及SonarQube Runner,并解压至新的目录NEW_SONARQUBE_HOME
http://www.sonarqube.org/downloads/
4.更新NEW_SONARQUBE_HOME/conf下sonar.properties与wrapper.conf文件里的内容,文件内容参照OLD_SONARQUBE_HOME/conf下相应配置文件的内容,但切记千万不要直接将原来的配置文件拷贝覆盖,因为新的sonar.properties与wrapper.conf文件还包含新版本的一些配置项。
5.拷贝OLD_SONARQUBE_HOME/extensions/plugins中的插件至NEW_SONARQUBE_HOME/extensions/plugins
6.如果使用的是自定义的JDBC驱动,将其拷贝至NEW_SONARQUBE_HOME/extensions/jdbc-driver/<dialect>
7.备份数据库:MySQL:
/usr/local/mysql# mysqldump -u sonar -p sonar>sonar.sql
8.启动SonarQube:
bin/<SYSTEM>/sonar stop
9.用浏览器访问http://localhost:9000/setup (注意:不再是直接访问localhost:9000),根据提示升级
10.根据实际情况修改系统中或持续集成中所有涉及SONAR_HOME和SONAR_RUNNER_HOME环境变量
11.使用新版SonarQube Runner分析项目
可能遇到的问题:
一、分析项目时报插件兼容性错误
解决:登录http://localhost:9000 WEB中配置——更新中心,将plugins都更新至最新版本
注:更新Java Plugin时将会有个警告,
- Version 2.4 moves Java from being an "ecosystem" of multiple plugins to a single, stand-along plugin that encompasses most of the functionality formerly contained in the ecosystem. Unfortunately, SonarQube's update center cannot handle the switch gracefully. You may use the update center to download the new version of the plugin. However,you must manually remove the Surefire, JaCoCo, and Squid for Java plugins from $SONARQUBE_HOME/extensions/plugins.
二、Impossible to upgrade database
原因:Sonar在MySQL中对表建立索引时,key的长度超过1000 bytes了,由于MySQL使用MyISAM engine时会有key长度
Migration failed: An error has occurred, all later migrations canceled: ActiveRecord::JDBCError: Specified key was too long; max key length is 1000 bytes: CREATE UNIQUE INDEX `rules_repo_key` ON `rules` (`plugin_name`, `plugin_rule_key`) .
Please check logs.
Please check logs.