Automate SonarQube Scans with GitHub Actions

Matt H
5 min readSep 29, 2021

Before you jump in I want to notate that this is specific to SonarQube as SonarCloud works out of the box with very little adjustments.

Graphic: Sonar Scan

Create SonarQube Project

First step would be to create a project for your repository in SonarQube. It’s a very simple process and there is a wizard that will walk you through it. Currently there are a few integration options for Azure DevOps, Bitbucket, GitHub, GitLab or manually. During this process you should also be taken to a screen to authenticate into your SCM of choice. Keep track of any tokens you create as you will need that later in the process.

Prerequisites

  • Admin access to SonarQube or the project
  • Admin access on your GitHub repository

Configuration

While it is easier to configure your project through the SonarQube UI, I recommend doing it through a configuration file included within your repo so that you’re able to have it version controlled.

The configuration file for SonarQube should live in the root directory and be named sonar-project.properties. I had a hard time finding a sample of what it should look like so I included one below. Please read through it and update all configurations to meet your projects…

--

--

Matt H
Matt H

Written by Matt H

Staff/Principal Software Engineer

No responses yet