2.2 Configure SonarQube with Jenkins

Step1: Set environment variables for SONAR_RUNNER_HOME

Open your environment variables window. Click new button in System variables section.

  1. Set a variable name SONAR_RUNNER_HOME and its value should be the unzipped path of sonar-runner zip file.

    Example:- variable name:- SONAR_RUNNER_HOME variable value:- C:\sonar-scanner

  2. And then append sonar-runner's bin path %SONAR_RUNNER_HOME%\bin to the environment variables path.

    Example:- variable name:- PATH variable value:- %SONAR_RUNNER_HOME%\bin;

Step 2:

a. Install the SonarQube Scanner for Jenkins via the Jenkins Update Center

b. Configure sonarqube server to Jenkins

  1. Configure your SonarQube server(s)

  2. Log into Jenkins as an administrator and go to Manage Jenkins > Configure System: Scroll down to the SonarQube configuration section, click on Add SonarQube, and add the values you're prompted for.

Generate the user token by logging into the SonarQube website and provide the key details in Jenkins for SonarQube versions above 5.2.

Step 3:Configure the tools in Jenkins Global Configuration

This step is mandatory if you want to trigger any of your SonarQube analyses with the SonarQube Scanner. You can define as many scanner instances as you wish. Then for each Jenkins job, you will be able to choose with which launcher to use to run the SonarQube analysis.

  1. Log into Jenkins as an administrator and go to Manage Jenkins > Global Tool Configuration

  2. Scroll down to the SonarQube Scanner configuration section and click on Add SonarQube Scanner. It is based on the typical Jenkins tool auto-installation. You can either choose to point to an already installed version of SonarQube Scanner (uncheck 'Install automatically') or tell Jenkins to grab the installer from a remote location (check 'Install automatically').

If you don't see a drop down list with all available SonarQube Scanner versions but instead see an empty text field then this is because Jenkins still hasn't downloaded the required update center file (default period is 1 day). You may force this refresh by clicking 'Check Now' button in Manage Plugins > Advanced tab.

Last updated