Getting Started with SonarQube on Scalingo
SonarQube is an automatic code review tool to detect bugs, vulnerabilities, and code smells in your project. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.
Planning your Deployment
-
SonarQube requires its own database. We usually advise to use a PostgreSQL® Starter or Business 512 addon for this purpose.
-
SonarQube requires quite a lot of RAM to run properly. You most probably won’t be able to deploy on a container smaller than 2XL.
-
SonarQube requires Java version 17 to run. We can instruct Scalingo to use this version of JAVA by using the
system.properties
file as described in our documentation.
Deploying
Using our One-Click Deploy Button
Click the One-Click Deploy button below to automatically deploy SonarQube with your Scalingo account:
Using the Command Line
We maintain a repository called sonarqube-scalingo on GitHub to help you deploy SonarQube Community Edition on Scalingo. Here are the few additional steps you will need to follow:
- Clone our repository:
git clone https://github.com/Scalingo/sonarqube-scalingo cd sonarqube-scalingo
- Create the application on Scalingo:
scalingo create my-sonarqube
Notice that our Command Line automatically detects the git repository, and adds a git remote to Scalingo:
git remote -v origin https://github.com/Scalingo/sonarqube-scalingo (fetch) origin https://github.com/Scalingo/sonarqube-scalingo (push) scalingo git@ssh.osc-fr1.scalingo.com:my-sonarqube.git (fetch) scalingo git@ssh.osc-fr1.scalingo.com:my-sonarqube.git (push)
- Provision a Scalingo for PostgreSQL® Starter 512 addon:
scalingo --app my-sonarqube addons-add postgresql postgresql-starter-512
- (optional) Instruct the platform to run the
web
process type in a single 2XL container:scalingo --app my-sonarqube scale web:1:2XL
- Everything’s ready, deploy to Scalingo:
git push scalingo master
The default credentials after a first deployment are
admin
andadmin
. After a first successful login, SonarQube asks you to update the admin password.
Using the Terraform Provider
-
Start by forking our SonarQube repository
- Place the following block in your Terraform file to create the app:
resource "scalingo_app" "my-sonarqube" { name = "my-sonarqube" stack_id = "scalingo-22" force_https = true }
- Link the app to your forked repository:
data "scalingo_scm_integration" "github" { scm_type = "github" } resource "scalingo_scm_repo_link" "default" { auth_integration_uuid = data.scalingo_scm_integration.github.id app = scalingo_app.my-sonarqube.id source = "https://github.com/<username>/sonarqube-scalingo" branch = "master" }
- Provision a Scalingo for PostgreSQL® Starter 512 addon and attach it to your
app:
resource "scalingo_addon" "my-sonarqube-db" { app = scalingo_app.my-sonarqube.id provider_id = "postgresql" plan = "postgresql-starter-512" }
- (optional) Instruct the platform to run the
web
process type in a single 2XL container:resource "scalingo_container_type" "web" { app = scalingo_app.my-sonarqube.id name = "web" size = "2XL" amount = 1 }
-
Run
terraform plan
and check if the result looks good -
If so, run
terraform apply
- Once Terraform is done, your SonarQube instance is ready to be deployed:
- Head to your dashboard
- Click on your SonarQube application
- Click on the Deploy tab
- Click on Manual deployment in the left menu
- Click the Trigger deployment button
- After a few seconds, your SonarQube instance is finally up and running!
Updating
By default, Scalingo tries to install the latest LTS version of the Community Edition.
Consequently, updating SonarQube only consists of triggering a new deployment of your instance.
Using the Command Line
- In your SonarQube repository, create an empty commit and push it to
Scalingo:
git commit --allow-empty -m "Update SonarQube" git push scalingo master
Using the Terraform Provider
- Head to your dashboard
- Click on your SonarQube application
- Click on the Deploy tab
- Click on Manual deployment in the left menu
- Click the Trigger deployment button
- After a few seconds, your updated SonarQube instance is ready!
Customizing
Installing Plugins
-
Copy the plugin(s) JAR archive(s) into the
plugins
folder of your repository -
Don’t forget to commit your changes:
git add plugins/ git commit -m "Add plugins"
The last steps depend on the method chosent to deploy your SonarQube instance (see below).
Using the Command Line
-
Make sure you have followed the first steps
-
From your SonarQube repository, trigger a new deployment:
git push scalingo master
Using the Terraform Provider
-
Make sure you have followed the first steps
- Push your changes to the repository linked to your app:
git push origin master
- Trigger a new deployment:
- Head to your dashboard
- Click on your SonarQube application
- Click on the Deploy tab
- Click on Manual deployment in the left menu
- Click the Trigger deployment button
Environment
SonarQube supports many environment variables.
Moreover, the buildpack makes use of the following environment variable(s). They can be leveraged to customize your deployment:
-
SONARQUBE_VERSION
Allows to specify the SonarQube version to deploy.
Defaults to the version set in the buildpack.