From 1f4176eec4fd7877820cc3e8718b3f35a8493dca Mon Sep 17 00:00:00 2001 From: Molzonas Date: Tue, 26 Aug 2025 13:05:47 +0200 Subject: [PATCH] .gitlab-ci.yml updated + add JUnit Took 9 minutes --- .gitlab-ci.yml | 70 ++++++++++++++++++++++++++++++++++++-------------- pom.xml | 7 +++++ 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62d95fd..0d50da0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,22 +1,54 @@ -# You can override the included template(s) by including variable overrides -# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings -# Secret Detection customization: https://docs.gitlab.com/user/application_security/secret_detection/pipeline/configure -# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings -# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings -# Note that environment variables can be set in several places -# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence -:stages: - - test -:sast: - :stage: test -:include: - - :template: Security/SAST.gitlab-ci.yml stages: - test - - secret-detection + - release + +image: maven:3.9.8-eclipse-temurin-21 + variables: - SECRET_DETECTION_ENABLED: 'true' -secret_detection: - stage: secret-detection -include: - - template: Security/Secret-Detection.gitlab-ci.yml + MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" + +cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - .m2/repository + +# MVN TEST + JUNIT REPORT +test: + stage: test + script: + - mvn -B -ntp test + artifacts: + when: always + reports: + junit: + - target/surefire-reports/*.xml + - target/failsafe-reports/*.xml + paths: + - target/surefire-reports + - target/failsafe-reports + rules: + - if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG + +# COMPILATION + RELEASE GENERATION +release: + stage: release + needs: ["test"] + script: + - mvn -B -ntp -DskipTests package + - JAR=$(ls target/*-with-dependencies.jar 2>/dev/null || ls target/*.jar | head -n1) + - cp "$JAR" "target/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.jar" + artifacts: + paths: + - target/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.jar + release: + name: "Release ${CI_COMMIT_TAG}" + tag_name: "${CI_COMMIT_TAG}" + description: | + New release : ${CI_COMMIT_TAG}. + Commit : ${CI_COMMIT_SHA} + assets: + links: + - name: "${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.jar" + url: "${CI_JOB_URL}/artifacts/raw/target/${CI_PROJECT_NAME}-${CI_COMMIT_TAG}.jar" + rules: + - if: $CI_COMMIT_TAG \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2be01c4..3df999c 100644 --- a/pom.xml +++ b/pom.xml @@ -96,5 +96,12 @@ 3.10.2 provided + + junit + junit + 4.13.2 + test + +