0

SonarQube helps to highlight all SONAR violations and in the analysis of each Pull Request code change when done on the local system.

Is there any option/set-up where I can automate any Pull Request to be analyzed by SonarQube in GIT and send out an email or update a dashboard with the latest SONAR code violations? All I want is to automate the SONAR analysis as soon as someone initiates a pull request.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102

1 Answers1

0

You would need to have a third component namely the CI server. This is the TL;DR solution for is how I did it full version in https://www.trajano.net/2016/11/integrating-travis-sonarqube/

  1. Create tokens for your account in SonarQube.com accounts security.
  2. Create a GitHub personal access token with repo access.
  3. Enable Travis build for your repository.
  4. Create a .travis.yml file.
    language: java
    jdk:
      - oraclejdk8
    sudo: false
    cache:
      directories:
      - "$HOME/.m2"
      - "$HOME/.sonar/cache"
    addons:
      sonarqube: true
    install:
    - mvn dependency:go-offline
    script:
    - mvn install site -Dmaven.test.failure.ignore=true
    after_success:
    - mvn sonar:sonar
  1. Add the tokens using travis encrypt
    travis encrypt SONAR_TOKEN=[token from sonarqube.com]
    travis encrypt SONAR_GITHUB_TOKEN=[token from github.com]
Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265