Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-sonnet-20241022· AnthropicHugging Face LMArena Human Preference 140K

should i put the cache: paths: outside the build-job and test-job? or then it would'nt…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b’s answer.
  1. User

    should i put the cache: paths: outside the build-job and test-job? or then it would'nt work?

  2. Claude Assistant

    You can define the cache at either level:

    1. Job-level (as shown in my previous example)
    2. 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-job
    

    Both 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.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.