The purpose of this service is for classes to be able to use Sonarqube to do code validation and review  on their projects to help them form better coding habits. The process uses a gitlab-runner to checkout and scan the code from, then upload the results to the sonarqube server.


Setting up a class:

Prior to the Semester, the instructor should contact and request a subgroup of clas-sonarqube be created for the class in ( e.g. clas-sonarqube/cs-XXXX-20XX-Fall). The instructor will then be able to create subgroups (sonarqube/cs-XXXX-20XX-Fall/team_1) and assign members and permissions to that class. All of the git projects created under these subgroups will have access to the gitlab-runner provided by sonarqube. Everyone will need to log in to at least once before permissions can be added.

Note: the projects and subgroups will be removed shortly after the end of the course.

Setting up a Sonarqube project:

  1. Log into with your HawkID and password. NOTE: If you are off-campus, you will need to connect to the university VPN to access the sonarqube website. 
  • go to "projects tab" → "add project" → "manually"

Shows how to navigate to manually​​​​​​

  • create a project key → "set up"
  • generate a token and copy it
  • press "continue"
  1. The students using the gitlab-runner will need to have a subgroup of created for them. 
  2. Each student needs to log in once to 
  3. Send a request to the instructor or TA to create your subgroup
    1. The desired name of the subgroup to be created, and a list of the hawkids to be added as members of the subgroup.
    2. The name of the Instructor
    3. The name of the course
  • go to groups and go to the subgroup provided by your instructor

Sonarqube groups

  • find your class or group number folder within sonarqube and click it
  • create "New Project"
  • click on the "CI/CD configuration" → "Editor" → "Create new CI/CD pipeline" → delete the sample code and paste the following:  

CD/CI Pipeline



    name: sonarsource/sonar-scanner-cli:latest

    entrypoint: [""]


    SONAR_TOKEN: <replace with your token>

    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache

    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task


    key: "${CI_JOB_NAME}"


      - .sonar/cache


    - sonarqube


    - sonar-scanner

  allow_failure: true


    - main # or the name of your main branch

  • paste your sonarqube token in the code above where it says "<replace with your token>". Do not include the brackets.
  • set Target Branch to "main" or the name of your default branch 
  1. Create a file in your GitLab project named:

sonar.projectKey=<your key here>


  • paste your project key in the above file where it says "<your key here>"


  1. Now any code you commit will go through the sonarqube service. To view your sonarqube results, go back to  and look at your project.