> For the complete documentation index, see [llms.txt](https://n-saikiran.gitbook.io/jenkins/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n-saikiran.gitbook.io/jenkins/jenkins-configurations/22-configure-sonarqube-with-jenkins.md).

# 2.2 Configure SonarQube with Jenkins

***Step1:*****&#x20;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:***&#x20;

**a. Install the** [**SonarQube Scanner**](https://plugins.jenkins.io/sonar) **for Jenkins via the Jenkins Update Center**

![](/files/-M4S6meWY3jbOMF5rr2J)

**b. Configure sonarqube server to Jenkins**&#x20;

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.

![](/files/-M4S6meY5RZnvSx7ZsES)

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*').

   ![](/files/-M4S6me_YxIMkeH8DaGs)

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**.
