In this article, I’ll help you how to quick create a sonarqube with docker compose
Step 1: Create a file `docker-compose.yml` with content as below Link to file
Run command at the root folder docker-compose up -d
Step 2 : Access to the sonarqube localhost:9000
username/password default : admin/admin
Step 3: Manual Create a project ( type Javascript/Typescript)
Fill you project display name and project key
Select option “Locally” as image above. You will go to the next page Analyze your project
Click Generate to generate the token of that project
Click continue and you could see the guideline how to run scan with the token
Step 4: Download the sonar-scanner from the official page.
After download and unzip the package we need to add the sonar-scanner to $PATH env to easy to execute it in the terminal
#MACOSsudo nano /etc/paths
# print the PATH
echo $PATH
Example : I put the package in my folder sonarqube-locally
. You can look at the bin folder you can see 2 files sonar-scanner
& sonar-scanner-debug
For Windows user please take at this article
Grant permission to make the `sonar-scanner` & `java` can execute without error
chmod 755 bin/sonar-scanner (sonar-scanner-debug)
chmod 755 jre/bin/java
In case you got the error can’t execute download by security
Open the System Preference-> Security & Privacy ( Tab General ) Allow apps downloaded identified developer.
Step 5 : At the root folder of your project — Create a sonar-project.properties
content of the file similar as result at the Step 3
Open the terminal at the root folder and run command below
sonar-scannerINFO: Scanner configuration file: /Users/haithai/workspace/tools/sonarqube/sonarqube/MacOs/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/haithai/workspace/js-project/sonar-project.properties
...
...
INFO: ANALYSIS SUCCESSFUL, you can find the results at: http://localhost:9000/dashboard?id=Project-Javascript
INFO: Note that you will be able to access the updated dashboard
INFO: Analysis total time: 2:13.060 s
INFO: ----------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ----------------------------------------------------
INFO: Total time: 2:15.132s
INFO: Final Memory: 16M/57M
INFO: ----------------------------------------------------
Access the link and take a look at the report : http://localhost:9000/dashboard?id=Project-Javascript
Error Tracking
Error when running: 'run-node -v'. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: 'node -v'. Is Node.js available during analysis?
Solution: install the run-node global mode
npm install -g run-node