should i put the cache: paths: outside the build-job and test-job? or then it would'nt…
- User
should i put the cache: paths: outside the build-job and test-job? or then it would'nt work?
Assistant
You can define the cache at either level:
- Job-level (as shown in my previous example)
- Global level (outside jobs)
Here's how you can define it globally:
image: maven:3.9.9-eclipse-temurin-21-alpine cache: paths: - .m2/repository/ stages: - build - test - package build-job: stage: build script: - mvn clean package -DskipTests artifacts: paths: - target/ - .m2/ expire_in: 1 hour test-job: stage: test script: - mvn test -o dependencies: - build-jobBoth approaches will work. The main difference is:
- Global cache: All jobs will share the same cache
- Job-level cache: You have more fine-grained control over what each job caches
For your Maven dependencies case, using a global cache makes more sense since you want all jobs to share the same Maven repository cache.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.