SonarQube: Difference between revisions
Jump to navigation
Jump to search
Line 17: | Line 17: | ||
=Move to docker-compose= | =Move to docker-compose= | ||
Now got is working I move to docker-compose. We can use the existing volumes from above with external keyword. | Now got is working I move to docker-compose. We can use the existing volumes from above with external keyword. | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="yaml"> | ||
version: '3.7' | version: '3.7' | ||
services: | services: |
Revision as of 05:35, 16 November 2023
Introduction
This is how to install
docker pull sonarqube
docker volume create sonarqube-conf
docker volume create sonarqube-data
docker volume create sonarqube-logs
docker volume create sonarqube-extensions
docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 -v sonarqube-conf:/opt/sonarqube/conf -v sonarqube-data:/opt/sonarqube/data -v sonarqube-logs:/opt/sonarqube/logs -v sonarqube-extensions:/opt/sonarqube/extensions sonarqube
Remember you can restart docker container if one exists with
docker restart <container>
Move to docker-compose
Now got is working I move to docker-compose. We can use the existing volumes from above with external keyword.
version: '3.7'
services:
sonarqube:
image: sonarqube
container_name: sonarqube-bill
ports:
- '9000:9000'
- '9092:9092'
volumes:
- 'sonarqube-conf:/opt/sonarqube/conf'
- 'sonarqube-data:/opt/sonarqube/data'
- 'sonarqube-logs:/opt/sonarqube/logs'
- 'sonarqube-extensions:/opt/sonarqube/extensions'
volumes:
sonarqube-conf:
external: true
name: sonarqube-conf
sonarqube-data:
external: true
name: sonarqube-data
sonarqube-logs:
external: true
name: sonarqube-logs
sonarqube-extensions:
external: true
name: sonarqube-extensions
Setting up the Scanner
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
I changed by .bashrc to have for next time
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
From there we can generate a token by going to http://localhost:9000/admin/users and look for the token column
Once you have one of there you can do
export SONAR_TOKEN=squ_3c567e0e8c92686895ddblahblah
sonar-scanner -Dsonar.projectKey=testvite2 -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000
Parameters to set in Sonar
"sonar.exclusions": "**/*.test.tsx",
"sonar.tests": "./src",
"sonar.test.inclusions": "**/*.test.tsx,**/*.test.ts",
"sonar.typescript.lcov.reportPaths": "coverage/lcov.info",
"sonar.testExecutionReportPaths": "test-report.xml"
And testing
"sonar.exclusions": "**/myTests/**",
"sonar.tests": "./src/myTests",
"sonar.test.inclusions": "./src/myTests/**/*.test.tsx,./src/myTests/**/*.test.ts"