• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Install | SonarQube (a SonarQuebe server to monitor the code quality)
  1. References
  2. Installation (Ubuntu 18.04)
  3. SonarQube configuration
  4. PostgreSQL configuration
  5. Maven configuration
  6. Run SonarQube analysis
  7. Run local SonarQube analysis
  8. Install plugins

  1. References
    See this page for more details about SonarQube: http://docs.sonarqube.org/display/SONAR/Documentation

    Prerequisites:
    • Install Apache Maven
    • Install PostgreSQL Database
    • Install Subversion
  2. Installation (Ubuntu 18.04)
    Download SonarQube (if the link is broken, please visit this page https://www.sonarqube.org/downloads/):

    Extract the file "sonarqube-7.9.1.zip" in the folder you want to install SonarQube: /opt/sonarqube-7.9.1

    Change the folder permissions:

    Create a symbolic link of the SonarQube installation folder:
  3. SonarQube configuration
    Add (or uncomment and modify) the following configuration in the "/opt/sonarqube/conf/sonar.properties" file:

    SonarQube requires some settings to be configured properly. Please visit this page for more details https://docs.sonarqube.org/7.9/requirements/requirements/

    Set JVM (Java 11) executable path:

    Edit "/etc/sysctl.conf" file:

    Run "sysctl -p" to refresh the new configuration of the "/etc/sysctl.conf" file:

    Increase the open files limit:



    You might need to reboot your system so the open files limit configuration get applied.

    Start SonarQube:

    Access the default page of SonarQube: http://localhost:9000/

    Welcome - SonarQube

    To login to SonarQube, click the "Log in" file and enter:
    Login: admin
    Password: admin

    Note that SonarQube is using an embedded database.

    Other SonarQube commands:

    Log directory: "/opt/sonarqube/logs/"
  4. PostgreSQL configuration
    Please see this page for details on how to install and configure PostgreSQL: Install PostgreSQL Database

    Stop SonarQube:

    Create a PostgreSQL database named "sonar" and a user named "sonar":

    Add or uncomment and modify the following configuration in the "/opt/sonarqube/conf/sonar.properties" file:

    Start SonarQube:

    SonarQube will create the PostgreSQL schema:

    PostgreSQL Schema - SonarQube

    Note that you might get an error, when starting SonarQube, complaining about a failure executing a migration step.
    The issue is that SonarQube is failing to migrate an existing database so you might have to review the migration steps related to the version you want to upgrade.
    But you can also see this error if you have already started SonarQube using the embedded database before configuring PostgreSQL, in this case, if you don't care about this embedded database, just delete the content of the folders "temp" and "data" (located under SonarQube installation home folder).
    Make sure that SonarQube is not running before deleting the content of these folders.
  5. Maven configuration
    Add the following configuration to the "~/.m2/settings.xml" file:

    Note that you might need to configure SonarQube and add SVN credentials needed when running Sonar analysis.
    You can configure this by accessing this page on the SonarQube server: Administration -> Configuration -> SCM -> SVN
    Enter the Username and Password (+ additional properties if required).
    Please see this page for details on how to install and configure Subversion: Install Subversion

    Issues - SonarQube
  6. Run SonarQube analysis
    Create a local directory that will hold the maven project:

    Run the following command "mvn archetype:generate" to create the maven project:

    Run SonarQube analysis:

    Issues - SonarQube
  7. Run local SonarQube analysis
    Please note that the parameter "sonar.analysis.mode" was deprecated.
    If you use this parameter you will get this error: The preview mode, along with the 'sonar.analysis.mode' parameter, is no more supported. You should stop using this parameter.

    If you are using an old version of SonarQube (where the parameter "sonar.analysis.mode" is supported), you can run a local SonarQube analysis:

    Open the two files "issues-report.html" and "issues-report-light.html" in a browser to see the SonarQube Issues Report.
  8. Install plugins
    Connect to the Administration page.
    Click the "Log In" link and provide the login and password (login=admin, password=admin)

    Click the "Administration" link.
    Click the "Marketplace" link.

    Marketplace - SonarQube

    Select/search the plugin you want to install.
    For example you may be interested in installing the following plugins:

    • Checkstyle: Provide Checkstyle rules for Java projects

    • Findbugs: Provide Findbugs rules for analysis of Java projects

    • SonarXML: Enables scanning of XML files


    Restart SonarQube to complete the installation of the plugins (you can restart it directly from the SonarQube UI).

    You can find the installed plugins in this folder: "/opt/sonarqube/extensions/plugins/"
© 2025  mtitek