Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
en:modul:m324_aws:topics:11 [2025/10/15 14:22] – angelegt dgaravaldien:modul:m324_aws:topics:11 [2026/01/10 10:21] (aktuell) – [Getting started] dgaravaldi
Zeile 24: Zeile 24:
   * A text editor or IDE   * A text editor or IDE
  
 +\\
 === Step 1: Download and start SonarQube === === Step 1: Download and start SonarQube ===
 SonarQube must be run on servers or virtual machines because it is an on-premise solution (VMs). Without having to explicitly configure the server on your system, starting up an instance can be replaced by installing a Docker container from the Sonar image. SonarQube must be run on servers or virtual machines because it is an on-premise solution (VMs). Without having to explicitly configure the server on your system, starting up an instance can be replaced by installing a Docker container from the Sonar image.
Zeile 39: Zeile 40:
 </code> </code>
  
 +\\
 === Step 2: Create a new project === === Step 2: Create a new project ===
   * As Project type select ''Create a local Project''   * As Project type select ''Create a local Project''
-Then set ''Project display name and key'' and the ''main branch name (default: main)''.+  * Then set ''Project display name and key'' and the ''main branch name (default: main)''. 
 +  * Hit the button ''Next'' 
 +  * Select ''Follows the instance's default''
   * Hit the button ''Create project''   * Hit the button ''Create project''
  
 +\\
 === Step 3: Analysis method === === Step 3: Analysis method ===
   * As analysis method select ''Locally''   * As analysis method select ''Locally''
Zeile 49: Zeile 54:
   * Save the generated token and handle it as password.   * Save the generated token and handle it as password.
   * Hit the button ''Continue''   * Hit the button ''Continue''
 +  * Run analysis on your project: ''Other'' -> ''Linux''
  
 +
 +
 +\\
 === Step 4: Download and unzip the scanner === === Step 4: Download and unzip the scanner ===
   * Download the scanner for your platform.   * Download the scanner for your platform.
-  * Unzip it either in your project directory or where your tools are usually stored.  + 
-  * Add the ''bin'' directory of the unzipped folder in your ''PATH'' variable.+{{:en:modul:m324_aws:topics:01-sonar.png?direct&400|}} 
 +{{:en:modul:m324_aws:topics:02-sonar.png?direct&400|}} 
 + 
 +  * Unzip it either in your project directory or in your binary-directory. 
 +Example for Linux on AWS EC2 
 +<code> 
 +wget -N https://binaries.sonarsource.com/<whatever-path>/sonar-scanner-cli-<whatever-version>-linux-x64.zip 
 +sudo apt install unzip 
 +unzip -o sonar-scanner-cli-<whatever-version>-linux-x64.zip 
 +</code> 
 + 
 +  * Add the ''bin'' directory of the unzipped folder in your ''PATH'' variable and check with command ''whereis''Example: 
 +<code> 
 +whereis sonar-scanner 
 +sonar-scanner: /home/ubuntu/sonar/bin/sonar-scanner 
 +</code> 
   * Check before running code coverage that your target app (i.e. traffic light api) has the following node package are installed.   * Check before running code coverage that your target app (i.e. traffic light api) has the following node package are installed.
  
Zeile 86: Zeile 110:
 </code> </code>
  
 +\\
 === Step 5: Run the tests === === Step 5: Run the tests ===
 +  * On Linux: Install jest with ''sudo npm i jest-cli -g''
   * Run first the code coverage with jest.   * Run first the code coverage with jest.
  
Zeile 94: Zeile 120:
  
   * Execute the scanner as shown.   * Execute the scanner as shown.
-In the example the scanner binaries are stored in the project folder. The path to the scanner is used in a bash script. 
  
 <code> <code>
-#!/usr/bin/env bash+#!/usr/bin/bash 
 +# Attention: 
 +# Change CRLF (Windows) to LF (Unix on AWS) in your Editor
 # #
-# set tool variable +sonar-scanner 
-tool=??/M324_Code/sonar-scanner/bin/sonar-scanner.bat +  -Dsonar.projectKey=<YOUR-PROJECT-KEY> \ 
-# run tool +  -Dsonar.sources=. \ 
-$tool+  -Dsonar.host.url=<YOUR-HOST-URL>
 +  -Dsonar.token=<YOUR-TOKEN>
 +  -Dproject.settings=./sonar-project.properties
 </code> </code>
  
   * Analyse the generated report in SonarQube   * Analyse the generated report in SonarQube
  
----+{{:en:modul:m324_aws:topics:03-sonar.png?direct&800|Sample report from sonar}} 
  
-Based on [[https://www.aviator.co/blog/implementing-sonarqube-code-coverage-in-a-simple-javascript-application/|source]]. 
  
 ---- ----
 +Source: [[https://www.aviator.co/blog/implementing-sonarqube-code-coverage-in-a-simple-javascript-application/]].
  
 [[https://creativecommons.org/licenses/by-nc-sa/4.0/|{{https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png}}]] Daniel Garavaldi [[https://creativecommons.org/licenses/by-nc-sa/4.0/|{{https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png}}]] Daniel Garavaldi
  • en/modul/m324_aws/topics/11.1760530979.txt.gz
  • Zuletzt geändert: 2025/10/15 14:22
  • von dgaravaldi