This version of the SonarQube documentation is no longer maintained. It relates to a version of SonarQube that is not active.

Setting up Jenkins

This page explains how to set up Jenkins globally for the integration with SonarQube by using SonarQube extension for Jenkins.

This section explains how to set up Jenkins globally for the integration with SonarQube by using SonarQube extension for Jenkins. This extension is not mandatory but allows a centralized installation and setup of the scanner directly from Jenkins.

Proceed as follows:

  1. Install the SonarQube extension for Jenkins.

  2. Install the SonarScanner from Jenkins.

  3. If you have the Developer Edition of SonarQube or higher: set up the multi-branch features.

These steps are explained below.

Installing the SonarQube extension for Jenkins

SonarQube extension for Jenkins version 2.11 or later is required.

Proceed as follows:

  1. From the Jenkins Dashboard, navigate to Manage Jenkins > Manage Plugins and install the SonarQube Scanner plugin.

  2. Back at the Jenkins Dashboard, navigate to Credentials > System from the left navigation.

  3. Click the Global credentials (unrestricted) link in the System table.

  4. Click Add credentials in the left navigation and add the following information:

    • Kind: Secret Text

    • Scope: Global

    • Secret: Generate a token at User > My Account > Security in SonarQube, and copy and paste it here.

  5. Click OK.

  6. From the Jenkins Dashboard, navigate to Manage Jenkins > Configure System.

  7. From the SonarQube Servers section, click Add SonarQube. Add the following information:

    • Name: Give a unique name to your SonarQube instance.

    • Server URL: Your SonarQube instance URL.

    • Credentials: Select the credentials created during step 4.

  8. Click Save

Installing the SonarScanner instance(s)

From Jenkins, install and configure the SonarScanner instance(s). This step depends on the project type.

  1. Log into Jenkins as an administrator and go to Manage Jenkins > Configure System.

  2. Scroll to the SonarQube servers section and check Enable injection of SonarQube server configuration as build environment variables.

Setting up the multi-branch features

From SonarQube Developer Edition, you can use multi-branch features.

To be able to analyze Jenkins Multibranch Pipeline jobs, you must:

  1. On your CI host, install the Branch Source plugin for Jenkins corresponding to your DevOps platform.

Bitbucket Branch Source plugin version 2.7 or later is required

From the Jenkins Dashboard, navigate to Manage Jenkins > Manage Plugins and install the Bitbucket Branch Source plugin. Then configure the following:

  1. From the Jenkins Dashboard, navigate to Manage Jenkins > Configure System.

  2. From the Bitbucket Endpoints section, open the Add drop-down menu and select Bitbucket Server. Add the following information:

    • Name: Give a unique name to your Bitbucket Server or Data Center instance.

    • Server URL: Your Bitbucket Server or Data Center instance URL.

  3. Select Save.

2. Check the prerequisites and perform the global setup for Pull request analysis and Branch analysis.

Other settings

If applicable, configure Webhooks at global level to be used for pipeline jobs to set up an Setting up a pipeline pause.

Last updated

Was this helpful?