add the build.gradle
code to your top-level gradle file and module.gradle
code to your module gradle file.
Take care to put the projectName
and projectVersion
names, as well as to put the correct report paths, androidVariant
name and task names. Check that you have SONAR_LOGIN
set in the CI environment.
You can now test that the reports are sent correctly by executing ./gradlew sonarqube
and checking the sonarqube project dashboard to make sure your project is there.
If you use fastlane
, also add this to your fastlane\Fastfile
:
lane :sonarqube do
gradle(task: "sonarqube")
end
Don't forget to add the task to the CI file, e.g. .gitlab-ci.yml
:
sonarqube_reporting:
stage: report
except:
- master
before_script:
- bundle install
script:
- bundle exec fastlane sonarqube --verbose
artifacts:
paths:
- app/build/reports/jacoco
Lastly, if you want to have a nice badge with metrics in your README.md
page (or any other Markdown page) like this:
you can add this: [![coverage](https://sonarqube.unterwegs.io/api/badges/measure?key=navigation-android&metric=coverage)](https://sonarqube.unterwegs.io/component_measures/metric/coverage/list?id=navigation-android)
(this shows coverage for navigation-android
project). To check more badge examples, visit the badge homepage.
@mrsasha How can you force build failed on gitlab if sonarqube doesn't follow quality metrics?