From f55b7e4817bba9f70129b1bf206b32545cf9936e Mon Sep 17 00:00:00 2001
From: Orestis <orestis.malaspinas@pm.me>
Date: Wed, 14 Feb 2024 11:13:52 +0100
Subject: [PATCH] sonar integration

---
 NodeApp/.gitlab-ci/04_stageCodeQuality.yml | 24 +++++++++++++++++++++-
 sonar-project.properties                   |  3 +++
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 sonar-project.properties

diff --git a/NodeApp/.gitlab-ci/04_stageCodeQuality.yml b/NodeApp/.gitlab-ci/04_stageCodeQuality.yml
index 34da3c8..5722bf9 100644
--- a/NodeApp/.gitlab-ci/04_stageCodeQuality.yml
+++ b/NodeApp/.gitlab-ci/04_stageCodeQuality.yml
@@ -9,4 +9,26 @@ code_quality:lint:
         - npm install
         - npm run lint
     rules:
-        -   if: '$CI_COMMIT_TAG =~ "/^$/"'
\ No newline at end of file
+        - if: '$CI_COMMIT_TAG =~ "/^$/"'
+
+code_quality:sonarqube:
+    stage: code_quality
+    tags:
+        - code_quality
+    image:
+        name: leadrien/isc-sonar-scanner-cli
+        entrypoint: [""]
+    variables:
+        SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
+        GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
+    cache:
+        key: "${CI_JOB_NAME}"
+        paths:
+            - .sonar/cache
+    script:
+        - sonar-scanner
+    allow_failure: true
+    only:
+        - merge_requests
+        - main
+        - develop
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..af4b65c
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,3 @@
+sonar.projectKey=dojocli
+sonar.qualitygate.wait=true
+
-- 
GitLab