Wednesday 13 February 2019

Running SonarQube locally with Docker: End to End


Running SonarQube with Docker in local Environment

docker pull sonarqube

$ docker run -d --name sonarqube -p 9000:9000 sonarqube

Once the installation is complete open sonarqube in Browser

http://localhost:9000


To see if the docker container is running in cmd  type 
docker container ls

ece799069a5f        sonarqube                                             "./bin/run.sh"           2 hours ago         Up 2 hours          0.0.0.0:9000->9000/tcp   reverent_goldwasser

By default you can login as admin with password admin, see authentication documentation. 
In the dashboard:
Create New Project
Enter Project Key>SetUp
Generate the token and Copy it
Select the Project Main Language,I have selected JavaScript
Download and unzip the Scanner for macOS

Configure the environment path for SonarQube in .bash profile by giving the path of the bin directory of SonarQube.It will be something like this:


Users/saif.siddiqui/Downloads/sonar-scanner-3/bin

To analyze a javascript project navigate to the project directory and run 

sonar-scanner \
  -Dsonar.projectKey=ProjectName
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=Token\
 -Dsonar.exlusion=.node_module

OR

Running through configuration file 

Create sonar-project.properties file in the project directory to be scanned using command:

touch sonar-project.properties

Add this configuration to run js,jsx file:

sonar.projectKey= ProjectName \

sonar.sourceEncoding=UTF-8

sonar.javascript.file.suffixes=.js,.jsx
sonar.sources=detox/e2e
sonar.host.url=http://localhost:9000
sonar.login=generatedtoken
sonar.exclusions=.node_module


In the above code,sonar.javascript.file.suffixes=.js,.jsx will run only js,.jsx file other files will be ignored.
-sonar.sources will run the files in detox/e2e
-sonar.exclusions will exclude the node_module folder
Go to the project directory and run Sonar-Scanner 




Navigate to the Sonarqube Dashboard and Refresh,you will see the result something like this:




Interview Experience with AMAZON for the role of Quality Assurance Tester

This role was for Digital/ IoT/Mobile Application based testing :)  Amazon is a dream company and everyone wants to work for that company a...

Popular Posts