Last active
December 27, 2020 12:09
-
-
Save ryu1kn/7108cbbda377eb56a90ff55d51de8111 to your computer and use it in GitHub Desktop.
Use SonarQube to analyse a project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# | |
# 1. `make qube` to bring up SonarQube server | |
# 2. Open http://localhost:9000 with your browser, | |
# setup a new project (e.g. my-first-project) and generate a token. | |
# Put the token and project key in this Makefile | |
# 3. `make scan` against the repository you want to analyse | |
# Refs | |
# | |
# * https://docs.sonarqube.org/latest/setup/get-started-2-minutes/ | |
# * https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ | |
sonar_qube_port := 9000 | |
sonar_token := token-generated-by-sonarqube | |
project_key := my-first-project | |
check_repo := /path/to/repo | |
qube: | |
docker run --rm -d --name sonarqube \ | |
-e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \ | |
-p $(sonar_qube_port):9000 sonarqube:latest | |
scan: | |
docker run --rm -t \ | |
--add-host=host.docker.internal:host-gateway \ | |
-e SONAR_HOST_URL="http://host.docker.internal:$(sonar_qube_port)" \ | |
-e SONAR_LOGIN=$(sonar_token) \ | |
-v "$(check_repo):/usr/src" \ | |
sonarsource/sonar-scanner-cli -Dsonar.projectKey=$(project_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment