sonar - GradedJestRisk/linux-training GitHub Wiki

Sonar

https://docs.sonarsource.com/sonarqube/latest/try-out-sonarqube/

A community edition is available for Javascript, Java You should request a licence (a trial is available) for T-SQL

Start Qube

Community edition

docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest

Developer edition

docker stop sonarqube
docker run -d --name sonarqube-developer -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:lts-developer
docker logs sonarqube-developer

Connect http://localhost:9000/ using default password

  • login: admin
  • password: admin

Change the password

Start scanner

https://docs.sonarsource.com/sonarqube/10.2/analyzing-source-code/scanners/sonarscanner/#sonarscanner-from-docker-image

Locate your source files

export SONAR_SOURCE=<PATH-TO-SOURCE>
export SONAR_PROJECT=
export SONAR_TOKEN=

Build configuraion

  • SONAR_SOURCE=
  • SONAR_PROJECT=
  • SONAR_TOKEN=

Start container

docker run \
--rm \
--network=host \
-e SONAR_HOST_URL="http://localhost:9000" \
-e SONAR_SCANNER_OPTS=-Dsonar.projectKey=$SONAR_PROJECT \
-e SONAR_TOKEN=$SONAR_TOKEN \
-v $SONAR_SOURCE:/usr/src \
sonarsource/sonar-scanner-cli -X

Get results

http://localhost:9000/