38

I want to set up Sonar with Jenkins. But I'm not sure if the Sonar site describes two different ways to do this or if there are two necessary steps:

As far as I understood it, it's two different ways. If this is the case, what is the difference and what are the advantages and disadvantages (between the Sonar itself and Sonar runner)?

BЈовић
  • 62,405
  • 41
  • 173
  • 273
user1338413
  • 2,471
  • 8
  • 29
  • 36

1 Answers1

52

If you want to analyse a project with SonarQube and Jenkins, here's what you need:

  • A SonarQube server up and running

  • A Jenkins server up and running with the SonarQube Scanner for Jenkins installed and configure to point to your SonarQube server

  • A job configured to run a SonarQube analysis on your project:

    • Using the default and standard SonarQube Scanner (suitable for most projects)

    • Using the SonarQube Scanner for MSBuild (for .NET solutions)

    • Using a post build action for Maven-based projects

Everything is described more in details on the SonarQube Scanner for Jenkins documentation page.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
  • 1
    No, you're not obliged to edit settings.xml: choosing the Sonar server that you've configured in the global Jenkins settings should be enough. – Fabrice - SonarSource Team Nov 21 '12 at 07:36
  • The link for "your Sonar server configured..." seems to be broken. http://docs.sonarqube.org/display/PLUG/Configuring+Jenkins+SonarQube+Plugin is probably where it went. – Ian H Oct 22 '15 at 09:40
  • @IanH Thanks for the notification, I've updated the links! – Fabrice - SonarSource Team Oct 22 '15 at 12:13
  • Now the Post Build Action is no longer recommended: "It is no longer recommended to use SonarQube maven builder. It is preferable to set up SonarQube in the build environment and use a standard Jenkins maven target.". So, it seems that you have to add a "sonar-project.properties" configuration file to every single job you want to analyze, using a Pre or a Post Build Step. It is not clear how to simply configure many jobs. – Jhack Nov 07 '15 at 22:31
  • Hello, If I'm not using maven, should sonar runner be on the same server than jenkins ? – Nymeria Nov 17 '15 at 12:02
  • The first link is dead again, I guess the correct one is now this: http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+Jenkins – asmaier Jan 26 '16 at 10:18