Adding Sonarqube reporting for Lint and test coverage to Android Kotlin project (multi-module)
build.gradle code to your top-level gradle file and
module.gradle code to each of your module gradle files.
Take care to put the
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
lane :sonarqube do gradle(task: "sonarqube") end
Don't forget to add the task to the CI file, e.g.
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.