title: How to use the "cache" in gitlab when trying to use files from two previously run jobs?
body: <p>I have the following <code>.gitlab-ci.yml</code> configuration:</p>
  <pre><code>stages:
    - stage1
    - stage2
    - stage3
  
  job1:
    stage: stage1
    rules:
      - if: $RUN != &quot;job3&quot;
        when: always
      - when: never
    script:
      - date &gt; data/test1.txt
    cache:
      key: test-cache
      paths:
        - data/test1.txt
  
  job2:
    stage: stage2
    rules:
      - if: $RUN != &quot;job3&quot;
        when: always
      - when: never
    script:
      - date &gt; test2.txt
    cache:
      key: test-cache
      paths:
        - test2.txt
  
  job3:
    stage: stage3
    rules:
      - if: $RUN == &quot;job3&quot;
    script:
      - cat data/test1.txt
      - cat test2.txt
    cache:
      key: test-cache
      paths:
        - data/test1.txt
        - test2.txt
  </code></pre>
  <p>The plan is to do the following:</p>
  <ol>
  <li>To run the pipeline with the variable <code>RUN</code> not defined, so that ONLY the two jobs <code>job1</code> and <code>job2</code> are run, but NOT <code>job3</code>. The two jobs <code>job1</code> and <code>job2</code> are supposed to add the files <code>data/test1.txt</code> and <code>test2.txt</code> to the cache, so they can be fetched later by <code>job3</code>.</li>
  <li>To run the pipeline with the variable <code>RUN</code> set to <code>run3</code>, which ONLY runs the job <code>job3</code>. This job is supposed to fetch the previously generated files from the cache, namely the two files  <code>data/test1.txt</code> and <code>test2.txt</code>.</li>
  </ol>
  <p><strong>Explanation:</strong></p>
  <p>In reality, the two jobs <code>job1</code> and <code>job2</code> are very time consuming jobs which also consume a lot of API calls. Therefore, I do not want to rerun them for no reason, as they would generate the same results anyway. I just want to &quot;store&quot; the results from these two jobs <code>job1</code> and <code>job2</code>, and &quot;fetch&quot; these results from a later running job (maybe a few days later). This <code>job3</code> will also run in the same pipeline in the same repo and on the same branch. as the jobs <code>job1</code> and <code>job2</code>.</p>
  <p><strong>Expected result:</strong></p>
  <p><code>job3</code> can use the two files from the cache created by <code>job1</code> and <code>job2</code>.</p>
  <p><strong>Observed result</strong>:</p>
  <pre><code>$ cat data/test1.txt
  cat: data/test1.txt: No such file or directory
  </code></pre>
  <p>I have the following questions:</p>
  <ol>
  <li>How can I fix this problem? What IS the problem?</li>
  <li>Where is this documented?</li>
  </ol>