From 8b2f831474c04d1b9547a0e813ba8fc985005837 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20=C5=81opatowski?= <llopat@man.poznan.pl>
Date: Tue, 18 Mar 2025 15:41:45 +0100
Subject: [PATCH] Added sonar scan CI job

---
 .gitlab-ci.yml           | 12 ++++++++++++
 sonar-project.properties | 15 +++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 sonar-project.properties

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d69b2e5..2b976a3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -28,6 +28,18 @@ test:
       protoc/bin/protoc --proto_path=api/proto/v1 --proto_path=third_party --go_out=plugins=grpc:pkg/api/v1 config-service.proto
       go test ./...
 
+sonar:
+  stage: test
+  image:
+    name: sonarsource/sonar-scanner-cli:latest
+    entrypoint: [""]
+  only:
+    - develop
+    - /^release/
+  script:
+    - sonar-scanner -Dsonar.host.url=${SONAR_HOST} -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.projectName=${SONAR_PROJECT_NAME} -Dsonar.branch.name=${CI_COMMIT_BRANCH} -Dsonar.login=${SONAR_LOGIN_TOKEN}
+  allow_failure: true
+
 build_and_push_latest_image:
   stage: build
   only:
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..269a37e
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,15 @@
+# must be unique in a given SonarQube instance
+#sonar.projectKey=my:project
+
+# --- optional properties ---
+
+# defaults to project key
+#sonar.projectName=My project
+# defaults to 'not provided'
+#sonar.projectVersion=1.0
+
+# Path is relative to the sonar-project.properties file. Defaults to .
+#sonar.sources=.
+
+# Encoding of the source code. Default is default system encoding
+#sonar.sourceEncoding=UTF-8
\ No newline at end of file
-- 
GitLab