It’s been a while since we talked about Sonar. I was a bit busy recently to discover new territories (see previous posts Elastic Software, Quality in the Cloud) so I am late in the update of my Sonar environment. Furthermore, there is a new release 3.0 with a bunch of new features.
So without further ado, the time has come for a Sonar upgrade.
Note that this is an upgrade of our entire environment, not simply of Sonar but also of outdated plugins or to update or to add new plugins. To get an idea of my setup, you can refer to this post Sonar – Our Environment.
We’ll start by checking:
- The plugins we want to quit: I tested a few plugins for which a license is needed and it has expired. I will remove those plugins.
- The plugins we want to upgrade, for which there is a new version.
- The new plugins we want to install.
and in this screen, we can see:
- Installed plugins.
- Available plugins not installed.
- Installed plugins with a new release available.
- New Sonar release(s) available.
The screen below shows four possible updates of plugins, of which one (the plugin Views) is incompatible with the current version of Sonar and will necessitate an upgrade of Sonar.
The update of my Sonar environment Sonar will therefore consist of:
- Remove obsolete plugins.
- Upgrade existing plugins.
- Upgrade Sonar.
- Upgrade of the plugin Views / installation of new plugins.
To delete an existing plugin, simply select it from the tab ‘Installed Plugins’ to see its description and a button ‘Uninstall’.
It is necessary to restart Sonar to see the updates. In our environment, it requires a Stop / Start of Tomcat.
Hey, I forgot to backup my Sonar database schema. Let’s do it while Tomcat is stopped.
Backup of the Oracle Sonar schema
I do my dumps using the command line EXPort with the following parameters:
- file: the filename of the dump;
- log: a log file to verify that the dump is correct;
- userid: the connexion settings to my Oracle instance, for the schema to backup.
Simpler is not possible.
Start Tomcat and return to the Update Center: the removed plugins no longer appear in the tab ‘Installed Plugins’.
Upgrading plugins is done through a similar procedure.
Except for the Views plugin that needs an upgrade of Sonar. That’s what we will do now.
The upgrade procedure is simple and logical, but I will systematically consult the Upgrade Guide, as it is easy to forget something.
First, get a zip of the new Sonar release 3.0 from the download page and extract it to a new directory: ‘C:\Soft\sonar\sonar-3.0’, in my environment.
We will then recover files specific to our environment fom the previous version (2.13.1 on my machine) to the new version:
- Copy the files ‘sonar.properties’ (with the parameters of the environment) and ‘wrapper.conf’ from ‘C:\Soft\Sonar\sonar-2.13.1\conf’ to ‘C:\Soft\Sonar\sonar-3.0\conf’.
- Copy the files .jar of the plugins installed in our current environment from ‘C:\Soft\Sonar\sonar-2.13.1\extensions\plugins’ to ‘C:\Soft\Sonar\sonar-3.0\extensions\plugins’.
- Copy the driver ‘C:\Soft\Sonar\sonar-2.13.1\extensions\jdbc-driver\oracle\ojdbc6.jar’ to the directory ‘C:\Soft\Sonar\sonar-3.0\extensions\jdbc-driver\oracle’ (depending on the database you are using).
- Create a new .war file to be installed under Tomcat, for this new Sonar release: launch the ‘C:\Soft\Sonar\sonar-3.0\war\build-war.bat’, that will create in this same directory a ‘sonar.war’ file.
Note: it is best to update first your Sonar environment with the deletion or update of plugins before installing a new version since (point 2 above) we copy the .jar files of these plugins to the directory of the new Sonar version.
Once Tomcat and Sonar restarted, you could get the following message:
The first time, I thought I did something wrong or that I had forgotten something. This is the reason why I systematically consult the Upgrade Guide: there is a last step that consists in updating the database from the Sonar ‘setup’ page. In my environment: http://localhost:8888/sonar/setup.
Upgrading (Sonar post-upgrade) / adding plugins
You remember that the latest version of the plugin Views only works with Sonar 3.0. As we have now installed it, we can now perform this ‘Views’ upgrade.
Again, you have to log in to access the Admin Update Center and proceed with the upgrade from the tab ‘Plugin Updates’:
Back in the Update Center, I can now verify the upgrade of the plugin Views and the installation of new plugins.
We have seen all possible cases of updating our Sonar environment: remove plugins, update/add plugins and upgrade Sonar release.
You can easily adapt this procedure to your own environment. Remember to always consult the upgrade guide and release notes.
I let you enjoy these new features.