Hey everyone,
This is a step-by-step guide for integrating SonarQube for Android project using docker. Without any further delay, let’s dive right in.
What is SonarQube?
According to the official documentation,
“SonarQube is an automatic code review tool to detect bugs, vulnerabilities, and code smells in your code.”
What is Docker?
Docker simplifies the process of developing applications. It provides a set of tools that allow developers to create, test and deploy applications in loosely isolated environments.
Prerequisites
Docker (https://cutt.ly/WG4feRX)
Android Development Environment
Starting SonarQube
Start the Docker engine and log in to your account. Next, Install the SonarQube image and run it with the below command in the terminal.
With this, it will print the container ID once SonarQube is up and running successfully. To access it: “http://localhost:9000/”. The default user and password is “admin”
Configure a SonarQube Project.
Once you logged in to your SonarQube instance. Select the project creation option as “Manually” to run the scan from your local codebase.
To set up the project provide a Display Name and Project Key.
Next, provide “Locally” as the way you want to analyse your repository.
To authenticate the user to perform the analysis, generate the token by providing a name
Performing an analysis
Add the sonar scanner plugin in your Project level Gradle.
Next, in your App level Gradle configure as below
Replace the PROJECT-NAME, PROJECT-KEY, and TOKEN with the generated and provided values in the previous steps. Inclusion and exclusion depend on your requirement.
Sync your Gradle and run the following command on your terminal.
After the build is successful access your project at “http://localhost:9000/projects” to view your project report
That’s it. Now you can review your project and improve your code quality. But this is a basic SonarQube Android setup. There are a lot of things you can do with SonarQube. Learn it, research it & share it. I hope you found this useful. Until next time 🙏 👋
Top comments (0)