To have Docker installed
- create the following subdirectories in the directory that you have the file
docker-compose.yaml:project,sq_data,sq_extensionsandsq_logs - dump the source code of the project into subdirectory
projectdirectly, NOT as a sub-subdirectory - on a shell session located in the directory that you have the file
docker-compose.yamllaunch docker-compose process executing:docker-compose up sq - when you see the log message
"SonarQube is up"on the shell you launch docker-compose command, open your browser at http://localhost:9000 - click over
"log in"button on the upper right corner of the page - login with credentials
admin/admin - click over tab
"Administration"tab - click over subtab
"Marketplace" - scroll down and click over
"install"button of next plugins to install them:Git,SonarCSS,SonarHTML,SonarJS,SonarTS,SonarXMLandYAML Analyzer(consider to install other plugins if you want) - scroll up and you will see the button
"Restart Server": click on it. You will prompted to restart on a dialog box, click over"Restart"button - when you see the log message
"SonarQube is up"on the shell session where you have launched docker-compose command, you will see the login page and you must to repeat the login process
On a new shell session located in the directory that you have the file docker-compose.yaml launch analysis process executing: docker-compose up scanner but consider to execute, previously, another processes like the 'testing' process or 'lint' process,... May be possible the results of this execution can be reused by Sonar Scanner.
When the process finishes, you can re-visit your SonarQube service.
Depending of the nature of your project and the tooling associated to its technology stack, may be possible you have to extend/modify some key files, lets say package.json. Let's explain this with an example.
If you add some magical option to lint analysis (if you have it defined), you can integrate the results. With next options:
-f json -o sq_lint_report.json
you will generate a report in JSON format that can could be used by SonarQube analysis, so now you must add also an extra option on file docker-compose.yaml, change next line (the last line) from this:
command: sonar-scanner -Dsonar.host.url=http://sq:9000 -Dsonar.projectKey=parlacat -Dsonar.scm.provider=git
to this:
command: sonar-scanner -Dsonar.host.url=http://sq:9000 -Dsonar.projectKey=parlacat -Dsonar.scm.provider=git-Dsonar.eslint.reportPaths=./sq_lint_report.json
As you can see the report path is relative to project directory.
- If may want to use
Dependency-Checkplugin. - To include information about test coverage/test execution see documentation.