From 0707a62b3b17750b764095a7adb4af386be58257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr>
Date: Wed, 25 Sep 2019 15:45:16 +0200
Subject: [PATCH] add sonar stage into gitlab-ci

---
 .gitlab-ci.yml | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 50067eb8..a5622116 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,9 +1,12 @@
 stages:
     - install
+    - sonar
     - build
     - deploy
 
 variables:
+    VERSION: "3.0"
+    SONARQUBE_URL: https://sonarqube.lam.fr
     CONTAINER_IMAGE: portus.lam.fr/anis/anis-client
 
 install:
@@ -19,7 +22,16 @@ install:
         policy: push
     only:
         refs:
-            - develop
+            - sonar
+
+sonar_scanner:
+    image: portus.lam.fr/ci-tools/sonar-scanner:latest
+    stage: sonar
+    script:
+        - sonar-scanner -Dsonar.projectKey=anis-client -Dsonar.sources=src -Dsonar.projectVersion=$VERSION -Dsonar.host.url=$SONARQUBE_URL -Dsonar.login=$SONAR_TOKEN
+    only:
+        refs:
+            - sonar
 
 build:
     image: docker:stable
@@ -35,7 +47,7 @@ build:
         policy: pull
     only:
         refs:
-            - develop
+            - sonar
 
 deploy:
     image: alpine
@@ -45,4 +57,4 @@ deploy:
         - curl -XPOST $DEV_WEBHOOK
     only:
         refs:
-            - develop
\ No newline at end of file
+            - sonar
\ No newline at end of file
-- 
GitLab