SonarQube: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 32: Line 32:
</syntaxhighlight>
</syntaxhighlight>
From there we can generate a token by going to http://localhost:9000/admin/users and look for the token column<br>
From there we can generate a token by going to http://localhost:9000/admin/users and look for the token column<br>
[[File:Sonar.jpg|500px]]<br>
[[File:Sonar.jpg | 500px ]]<br>
Once you have one of there you can do
Once you have one of there you can do
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">

Revision as of 00:56, 24 September 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>

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