From 4dbd90e47805b09317702ba643929f88322b94df Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@orange.com>
Date: Tue, 15 Jun 2021 18:39:36 +0200
Subject: [PATCH] fix(sonar): prevent shallow git clone (required by Sonar
 Scanner)

---
 templates/gitlab-ci-maven.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/templates/gitlab-ci-maven.yml b/templates/gitlab-ci-maven.yml
index 501a066..d450d09 100644
--- a/templates/gitlab-ci-maven.yml
+++ b/templates/gitlab-ci-maven.yml
@@ -473,6 +473,10 @@ mvn-build:
 mvn-sonar:
   stage: test
   extends: .mvn-base
+  variables:
+    # Tells git to fetch all the branches of the project, required by the analysis task
+    # see: https://docs.sonarqube.org/8.5/analysis/gitlab-cicd/#header-2
+    GIT_DEPTH: 0
   script:
     - sonar_autodetect_mr
     - if [[ "$SONAR_GITLAB_TOKEN" ]]; then sonar_extra_args="$SONAR_GITLAB_ARGS"; fi
-- 
GitLab