Sonarqube: check official docs for last pre-requisites
Local configuration with docker and docker compose:
- Docker latest version checked: 23.0.5
- Docker compose latest version checked: v2.17.3
Also check Docker Host Requirements section on Dockerhub Sonarqube
Run with docker command:
docker run -d --name sonarqube_geekshubs -p 9000:9000 -p 9092:9092 sonarqube
Access to url http://localhost:9000
Extract a user token with analysis rol enabled from sonrqube server.
Maven:
mvn sonar:sonar \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=<sonar-analysis-token>
Using sonar-scanner
:
sonar-scanner \
-Dsonar.projectKey=sonar-test \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=<sonar-analysis-token>
Docker for maven project:
docker run -it --rm -v ~/.m2.docker:/root/.m2 \
-v $PWD:/usr/src/ -w /usr/src/ \
maven:3.6.3-jdk-11 \
mvn clean verify sonar:sonar -Dsonar.login=<sonar-analysis-token> \
-Dsonar.host.url=http://10.1.0.141:9000
docker run \
--rm \
-e SONAR_HOST_URL="http://192.168.1.41:9000" \
-e SONAR_SCANNER_OPTS="-Dsonar.projectKey=org.sonarqube:sonarqube-scanner" \
-e SONAR_LOGIN="sqa_443b5ac66d698ea07571cc3bb2b931a4bcaa7300" \
-v $PWD:/usr/src \
sonarsource/sonar-scanner-cli
Run following sonarqube-postgres configuration file to start SonarQube and a PostgreSQL database.
Run in sonarqube-postgres dir:
$ git clone [email protected]:SonarqubeGeekshubs/environment-docker-compose.git
$ cd environment-docker-compose/sonarqube-postgres
$ docker compose up -d
Run following sonarqube-jenkins configuration file to start SonarQube, a PostgreSQL database and Jenkins CI.
Run in sonarqube-jenkins dir:
$ git clone [email protected]:SonarqubeGeekshubs/environment-docker-compose.git
$ cd environment-docker-compose/sonarqube-jenkins
$ docker compose up -d
Checkout Repository: https://github.com/mechero/code-quality-game
Update .env file:
BACKEND_VERSION=1.2.0
UI_VERSION=1.0.4
SONAR_SERVER=http://host.docker.internal:9000
SONAR_LOGIN=a5e40ca3915db3f046d31624c6dd5e40711fe1c5
LEGACY_DATE=2023-05-19
EARLYBIRD_DATE=2023-05-25
CAMPAIGNSTART_DATE=2023-05-19
Docker:
docker compose -f docker-compose-quboo.yml up