From 48d94389f74f882c78847a0fb9bb7e00a1479e6b Mon Sep 17 00:00:00 2001
From: Daniel Rainer <daniel.m.rainer@student.uibk.ac.at>
Date: Sat, 5 Mar 2022 16:32:37 +0100
Subject: [PATCH] Specify maven cache per job

---
 .gitlab-ci.yml | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4ef7bbe94..dca57eeb5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,5 @@
 image: jhipster/jhipster:v7.6.0
 
-cache:
-  - key: '$CI_COMMIT_REF_NAME'
-    paths:
-      - .maven/
-
 stages:
   - setup
   - lint
@@ -36,6 +31,10 @@ checkstyle:
   script:
     - ./mvnw -ntp checkstyle:check -Dmaven.repo.local=$MAVEN_USER_HOME
   needs: []
+  cache:
+    - key: '$CI_COMMIT_REF_NAME'
+      paths:
+        - .maven/
 
 prettier:
   stage: lint
@@ -77,6 +76,10 @@ maven-compile:
       - target/generated-sources/
     expire_in: 1 day
   needs: []
+  cache:
+    - key: '$CI_COMMIT_REF_NAME'
+      paths:
+        - .maven/
 
 maven-test:
   # DinD service is required for Testcontainers
@@ -103,6 +106,10 @@ maven-test:
     expire_in: 30 day
   allow_failure: true
   needs: []
+  cache:
+    - key: '$CI_COMMIT_REF_NAME'
+      paths:
+        - .maven/
 
 frontend-test:
   stage: test
@@ -136,6 +143,10 @@ sonar-analyze:
     - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://qe-sonarqube.uibk.ac.at/ -Dsonar.login=${SONAR_TOKEN_QE} -Dmaven.repo.local=$MAVEN_USER_HOME
     - ./mvnw -ntp org.jacoco:jacoco-maven-plugin:prepare-agent initialize sonar:sonar -Dsonar.organization=codeAbility -Dsonar.host.url=https://server.arctis.at/sonar/ -Dsonar.login=${SONAR_TOKEN} -Dmaven.repo.local=$MAVEN_USER_HOME
   allow_failure: true
+  cache:
+    - key: '$CI_COMMIT_REF_NAME'
+      paths:
+        - .maven/
 
 maven-package:
   stage: package
@@ -157,3 +168,7 @@ maven-package:
   #    script:
   #        - ./mvnw -ntp jib:build -Pprod -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=gitlab-ci-token  -Djib.to.auth.password=$CI_BUILD_TOKEN -Dmaven.repo.local=$MAVEN_USER_HOME
   when: manual
+  cache:
+    - key: '$CI_COMMIT_REF_NAME'
+      paths:
+        - .maven/
-- 
GitLab