1: Install Docker on windows::
1.1: download docker desktop application from https://www.docker.com/products/docker-desktop
1.2: Install the app to your windows system
1.3: Add below path to your environment variables
– C:\Program Files\Docker\Docker\resources\bin
– C:\ProgramData\DockerDesktop\version-bin
1.4: Go to “Command Prompt” and type “docker -v”. If you get the docker version, it is installed correctly on your system.
2: Install Sonarqube::
2.1: Go to command prompt
2.2: Execute command: “docker pull sonarqube”. It will download sonarqube to your system.
2.3: To run sonarqube, execute : “docker run sonarqube”
2.4: After the execution is completed, go to your browser and open http://127.0.0.1:9000/ in a new tab.
2.5: You will see login screen, use admin/admin as username and password.
2.6: Now go to http://127.0.0.1:9000/projects/create/ click on “Manually” to connect sonarqube with your local magento instance
2.7: Add Project Name and project key
2.8: Click on “Set up”
2.9: Select “Locally” option from the list
2.10: It will ask to generate a token for your project. Add a name for your token and click on generate.
2.11: It will generate a key. Copy and store the key in your system
2.12: Click on continue
2.13: Select “Other” for Magento project
2.14: Select your OS, in our case “Windows”
2.15: It will open a few details about the project and will ask you to install sonarqube scanner. (KEEP THE SCREEN OPEN, WE WILL NEED IT IN FUTURE)
3: Install Sonarqube scanner::
3.1: Go to https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ and download windows-64 bit scanner.
3.2: You can directly use the link : https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-windows.zip
3.3: It will download a zip file.
3.4: Extract the zip and put it in any location of your system. In our case let’s add it in D:\docker\sonar-scanner
3.5: Now go to Environment variable and add a new path “D:\docker\sonar-scanner\bin”
4: Connect sonarqube with your local magento instance::
4.1: First, go to the sonarqube screen where we were setting up our project.
4.2: Got to “Execute the Scanner” section, you will find a command provided to execute sonarqube on your project.
4.3: Copy the command
4.4: Now, go to your Magento’s root directory and create a new file with name: “sonar-project.properties”
4.5: Add below code in the file.
sonar.projectKey=Magento (Your Project Key you created in sonarqube at step 2.7)
sonar.projectName=Magento (Your Project Key you created in sonarqube at step 2.7)
sonar.sources=app/code
sonar.projectBaseDir=app/code
sonar.exclusions=/Test/, /registration.php sonar.test.exclusions=/Test/**
sonar.php.coverage.reportPaths=reports/clover.xml
4.6: Now open your magento root directory in command prompt/
4.7: Execute the command copied at 4.3
– sonar-scanner.bat -D”sonar.projectKey=Test” -D”sonar.sources=.” -D”sonar.host.url=http://127.0.0.1:9000″ -D”sonar.login=0d3ee79ef3db6b83d221ef12a727b2fcfc93fad9″
4.8: It will start scanning your app/code directory. Once completed, your browser page (step 2.15) will get refreshed and you will see a complete report for your app/code directory.