Skip to content

SonarQube

Thomas Amberg edited this page Nov 23, 2020 · 29 revisions

Installing the SonarQube service

Installing a local instance of the SonarQube service.

  • Download sonarqube-8.5.1.38104.zip

  • Unzip sonarqube-8.5.1.38104.zip as a non-root user.

  • On Windows, run sonarqube\bin\windows-x86-64\StartSonar.bat

  • On MacOS or Linux, run sonar.sh as a non-root user, e.g.

    $ cd sonarqube-8.5.1.38104/bin/macosx-universal-64
    $ ./sonar.sh console
    

For details, see https://docs.sonarqube.org/latest/setup/get-started-2-minutes/

Getting a new SonarQube project token

Adding SonarQube to your Android project

  • Open your Android project

  • Open the build.gradle file

  • After the buildscript { ... } block, add

    plugins {
        id "org.sonarqube" version "2.7"
    }
    

Running SonarQube with your project token

  • Open a terminal, type:

    $ cd YOUR_ANDROID_PROJECT_PATH
    $ ./gradlew sonarqube \
      -Dsonar.projectKey=YOUR_SONARQUBE_PROJECT_NAME \
      -Dsonar.host.url=http://localhost:9000 \
      -Dsonar.login=YOUR_SONARQUBE_PROJECT_TOKEN
    
  • Access the result on http://localhost:9000/

Troubleshooting

  • If permission denied: ./gradlew try:

    $ chmod +x gradlew