Start Free
10.6 | Analyzing source code | CI integration | Jenkins integration | Key features

Was this page helpful?

Key features of SonarQube integration with Jenkins

On this page

SonarSource provides an extension for Jenkins to enable smooth integration with Jenkins. With the SonarQube extension for Jenkins:

  • You can install the SonarScanner CLI, for Maven, for Gradle, or for .NET from Jenkins and centralize the configuration of SonarQube server connection details in Jenkins global configuration.
  • You can trigger the SonarQube analysis from your Jenkins Freestyle or Pipeline jobs using standard Jenkins build steps or Jenkins Pipeline DSL. Once the Jenkins job is complete, the extension will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.
  • You can configure an automatic failing of your pipeline in case your code fails the quality gate you defined in SonarQube: see below.
  • From SonarQube Developer Edition, you can also trigger the SonarQube analysis from your Jenkins Multibranch Pipeline jobs. 

Automatic interruption of your pipeline in case the quality gate fails

With the SonarQube extension for Jenkins, you can configure that your pipeline job fails in case the quality gate computed by SonarQube for your project fails. To do so, the extension makes webhook available: a webhook call must be configured in SonarQube to call back into Jenkins to allow the pipeline to continue or fail.  

The figure below illustrates the process:

  1. A Jenkins Pipeline job is started.
  2. The job triggers the analysis by the SonarScanner.
  3. The SonarScanner sends the results to the SonarQube Server.
  4. The SonarQube Server completes the analysis, computes the quality gate configured for the project, and checks if the project fails or passes the quality gate.
  5. The SonarQube Server sends the pass or failure result back to the Jenkins webhook exposed by the SonarQube extension for Jenkins.
  6. The pipeline job continues (in case of a pass) or fails (otherwise).

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License