If you have not been following along this series about creating an environment of code analysis with SonarQube, here are the items we need today:
- Installing a Java JDK.
- The installation of SonarQube.
- And the previous post about the installation of Jenkins.
You can also have a look at the documentation about configuring the SonarQube Jenkins Plugin, on the SonarSource website.
Download and install the plugin SonarQube Jenkins
Let’s start by launching Jenkins, the web application of the same name under Tomcat, located at http://localhost:8888/jenkins in my environment.
In the Administration page of Jenkins, activate the menu to manage plugins:
Search and select the SonarQube plugin. I suggest you do a search on the string ‘Sonar’ to quickly find the plugin in this particularly long list.
At the bottom of the page, click the button ‘Install without restart’: Jenkins starts the installation and once it is finished…
… tells us that the SonarQube plugin has been updated. We can return to the Administration page of Jenkins to select the setup menu, which will allow us to set our SonarQube installation.
Configuring the SonarQube Runner
Jenkins will use the SonarQube Runner (that we have installed previously) to run analysis of code.
Notice in this page the first line indicating the working directory of Jenkins, that we have configured in the previous post.
Then, Jenkins proposes us to configure or even install a JDK.
This is not necessary if you have proceeded as indicated during the installation of a Java JDK, creating a JAVA_HOME variable and declaring in the path of your PC, the directory containing the java executables (%JAVA_HOME%\bin).
Below, a section devoted to the SonarQube Runner will allow us to configure it. First, click the button to add an instance of SonarQube Runner.
This will open a section to enter its configuration:
In this section:
- Uncheck the automatic installation option.
- Enter a name for you SonarQube Runner instance.
- Enter its localisation.
And finally, do not forget to save your settings. It’s done.
The configuration of SonarQube into Jenkins will follow the same logic. In this same configuration page of the ‘Jenkins system’, locate the section dedicated to SonarQube:
Again, click the button to create a new SonarQube instance.
These are the same as those listed in our ‘sonar-properties’ file, to configure SonarQube. So just open this file to use the same parameters:
- The url of our SonarQube web application.
- The access to our database.
- The JDBC driver.
I mentioned also the Oracle user and password to access the SonarQube schema (even if I actually used the default values). I did not include a SonarQube user to perform the analyzes, since I had not done it either during the installation of the SonarQube Runner.
Et voilà. Now we can use Jenkins to create and run SonarQube analysis.
This will be the subject of our next post. Very soon.