From 028983072d7a9009f0248ecd26703af88ab0d239 Mon Sep 17 00:00:00 2001 From: Luca Ponzanelli Date: Thu, 7 May 2020 13:39:08 +0200 Subject: [PATCH] Resolve "Setup SonarQube pipeline for development branch" - Remove de.aaschmid.cpd, and sonarqube v2.7 gradle plugins - Add sonarqube and jacopo gradle plugins - Remove code_quality job and add sonarqube job in code_quality stage - Limit sonarqube analysis to dev branch only --- .gitlab-ci.yml | 14 +++++--------- build.gradle | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 309580e..06efd58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,14 +52,10 @@ test: reports: junit: build/test-results/test/TEST-*.xml -#Runs a quality check on the code and creates a report on the codes -code_quality: +sonarqube: + image: gradle:jdk11 stage: code_quality - allow_failure: true + only: + - dev script: - - gradle cpdCheck - artifacts: - paths: - - build/reports/cpd/cpdCheck.xml - #create a report on the quality of the code - expose_as: 'Code Quality Report' + - gradle build jacocoTestReport sonarqube -Dsonar.verbose=true -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.projectKey=$CI_PROJECT_ PATH_SLUG -Dsonar.projectName=$CI_PROJECT_PATH_SLUG -Dsonar.scm.disabled=True -Dsonar.coverage.jacoco.xmlReportPaths=./build/reports/jacoco/test/jacocoTestReport.xml diff --git a/build.gradle b/build.gradle index 52470bf..4f04b96 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { id 'org.springframework.boot' version '2.2.4.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' - id "de.aaschmid.cpd" version "3.1" - id "org.sonarqube" version "2.7" id 'java' + id 'jacoco' + id "org.sonarqube" version "2.8" } group = 'ch.usi.inf.sa4.sanmarinoes' version = '0.0.1-SNAPSHOT' @@ -51,3 +51,13 @@ gradle.projectsEvaluated { test { useJUnitPlatform() } + +jacocoTestReport { + reports { + xml.enabled true + } +} + +plugins.withType(JacocoPlugin) { + tasks["test"].finalizedBy 'jacocoTestReport' +}