It’s been a long time since I updated my SonarQube environment. Six months or more, I’m still in version 4.2, while the latest version is a 4.5.1 LTS (Long Term Support). Therefore a good candidate for installation.
This article Walking the Tightrope: Balancing Agility and Stability on the blog SonarSource describes the aims and objectives of such a version. This 4.5.1 release not only offers corrections but also many changes and new features.
This is not the first post I write about a SonarQube upgrade, you will find them all together under this part SonarQube – Installation on my blog. This article will be more concise, with referrals to these previous and detailed posts, when needed.
Action plans
I take my time to do an upgrade (especially that I don’t do that so often) because there is, if not a procedure, but at least a plan to follow. Starting with what I call the prerequisites.
I start by looking at what’s new and, above all, I check the upgrade documentation because even if I know it well, even if I can refer to a previous article on my blog, this process may vary and it did happen that I get an error for not following carefully these requirements. The installation or the update of SonarQube is not automatic, it is not a click on an executable to implement the software, there are some manual steps.
Besides these Upgrade Notes for version 4.5 list possible impacts on my SonarQube environment, the different analysis and projects in my repository, their configurations, and especially the potential conflicts with previous versions of plugins. For instance, I can see that I must remove the Technical Debt plugin – you know, the SQALE plugin that I use in all my tests – prior to installing this new version of SonarQube.
The SonarQube Update Center also gives me a global overview of the various plugins to update.
In order to acces it, I log as an Admin, and then the ‘Settings’ menu brings me to the page with the same name, in which I select the ‘Update Center’ menu (in the left menu bar) to go into in the same page ‘Update Center’ with different tabs. We first start with the tab ‘System Updates’ which allows me to check that:
- I can directly upgrade my installed version 4.2 to the latest version 4.5.1 without going through an intermediate version. Great!
- The upgrade procedure consists in a prior upgrade of some plugins before …
- … Installing the SonarQube 4.5.1 release.
But first, the last pre-requisite: a backup of the Oracle user (schema) Sonar. I did describe previously the complete procedure.
Plugins upgrade (1)
I begin by updating the plugins listed above by clicking on the ‘Upgrade’ for each of them … and get an error message:
Well, it’s like the dog chasing it’s tail: the tab ‘System Updates’ told me to upgrade some plugins before a SonarQube upgrade, but when I try to follow these instructions, this message indicates to me that we must first update the version of SonarQube before updating the plugins.
Moreover, this is what is clearly indicated in the tab ‘Plugin Updates’:
I tried to download and install a new version of the ‘Developer Cockpit’ plugin in the corresponding directory ‘..\Sonar\sonarqube-4.5.1\extensions\plugins’, then a Restart of the Sonar service, but unsuccessfully:
The log ‘..\Sonar\sonarqube-4.5.1\logs\sonar.log’ clearly tells me that I can not work with this version of this plugin for this version of SonarQube. In fact, this is the Upgrade Notes to version 4.5 that must be followed, so once again: always consult it before any action. I’ll remove the Technical Debt plugin, the only one deprecated in my environment (according to these notes), before installing the new version of SonarQube.
SonarQube upgrade
Detailed instructions can be found in a previous post SonarQube Upgrade 4-0. So I’ll list them briefly, unless we find anything new and different.
- Stop the current (4.2) Sonar service.
- Backup of the current SonarQube directory (‘..\Sonar\sonarqube-4.2’), for safety.
- Download of the ‘sonarqube-4.5.1.zip’ file from the Download page.
- Delete of the existing Sonar service with the file ‘..\Sonar\sonarqube-4.2\bin\windows-x86-64\UninstallNTService.bat’. Obviously, choose the directory for your operating system (Windows 7 64-bit for me).
- Copy of the plugins from the previous version to the new version, so from ‘..\Sonar\sonarqube-4.2\extensions\plugins’ to ‘..\Sonar\sonarqube-4.5.1\extensions\plugins’.
Note: for this particular installation of the 4.5.1 release, I will not copy the plugin Technical Debt, since it is deprecated and should be removed from the plugins directory, as described above. - Copy of the Oracle driver ‘ojdbc6.jar’ to the new directory ‘..\Sonar\sonarqube-4.5.1\extensions\\jdbc-driver\oracle’.
- As indicated on the SonarSource upgrade page, I update the configuration file ‘..\Sonar\sonarqube-4.5.1\conf\sonar.properties’ with the characteristics of my environment, principally the address of my Oracle database. We could do the same with the file ‘wrapper.conf’ (for the JVM configuration), but I prefer to start with the default configuration and possibly consider some adjustments in case of problems.
Changes in the file ‘sonar.properties’ are typically as follows:
- Oracle user for the Sonar scheme: these lines are already commented in the file. So just quit the sign ‘#’ in front of it.
Okay. I can now start the installation of the new service for this SonarQube version with the file ‘..\Sonar\sonarqube-4.5.1\bin\windows-x86-64\‘InstallNTService.bat’. Again, choose the folder that corresponds to your OS.
Ok. Installation performed correctly:
The new service ‘SonarQube’ (and not ‘Sonar’ as in the previous version 4.2) appears in the list of the Windows services.
And when I run it, I get an error message already met in a previous upgrade. The problem is that the account ‘Local System’ attempts to start the service, which does not work on my laptop. May be you won’t have this problem for a server installation, but if that’s the case on your own computer, follow the steps in this post to change the user launching the service.
I start the service, then SonarQube: http://localhost:9000/ (default url). We go on the maintenance page.
This is correct, we still have to proceed with the last step: the upgrade of the database from the setup page: http://localhost:9000/setup.
This may take some time, depending on the data in your repository SonarQube, that is to say the number and size of your projects.
Ultimately, SonarQube tells us that the database is updated correctly. This is the signal that our version upgrade has worked (at least, until we start an analysis).
Plugins upgrade (2)
Now that my version of SonarQube is up to date, I can proceed with the upgrade of the plugins, from the tab ‘Plugin Updates’, by clicking on all buttons of upgrade to the latest version for each of the plugins.
Unfortunately, this does not work, I get an error message about the plugin ‘surefire’, which must be fully compatible with the ‘java’ plugin version.
And when I remove it from the plugins directory, the upgrade is interrupted again with another error message about the plugin ‘jacoco’, then ‘squid’ … even though these plugins are not present in the list above.
Actually, and again, we must first of all visit the plugins page to check for Upgrade Notes, as this is the case for the various Java plugins http://docs.sonarqube.org/display/SONAR/Java+Plugin.
I follow the instructions listed on this page and remove the listed plugins, and then the upgrade of the other plugins works Ok without error. I can then reinstall the Java plugins easily.
Synthesis
So as a summary, some important points to note:
- Prerequisites: always look at the Releases or Upgrade notes, and not only for SonarQube but also for the plugins that you wish to update.
- The Update Center is very valuable to get a global and precise view of the installed plugins and the new versions, and thus prepare the upgrade procedure.
- The Update Center does not always allow to automatically upgrade: some preliminary steps, such as a manual removal of a version of some plugins, are sometimes necessary, as we have seen above.
Our SonarQube environment is now updated. I am eager to see the new quality rules for SAP (ABAP) and Cobol code. In a future post.
This post is also available in Leer este articulo en castellano and Lire cet article en français.
dear friend ,I read your blog and come to know that you have good knowledge in sonarqube, I use sonarqube for my project, Iam new to this tool so I used sonarqube 3.5 and sonar runner 2.1 jdk 1.6, no sql, since embedded, I am using through vdi and SVN is preinstalled so no plugins,Iam able to install the sonarqube since when I type localhost:9000 I could get the successful page,and I even accessed the projectcode through svn and made it available,after this analysis is a big headache,i am stucked because I don’t know next what to do in windowsxp?can you please help me in this situation…
I would recommend that you install Jenkins in order to launch your analysis. This post is a little bit old but it should help you http://qualilogy.com/en/upgrade-sonarqube-runner-jenkins/.
Here you have an example of creation of a job of analysis in Jenkins http://qualilogy.com/en/plsql-analysis-sonarqube-configuration/.
Good luck.