Answers: <p>It seems you're trying to define the artifacts globally, that won't work with multiple paths since you're overwriting the definition of the key. Instead you should define the paths per job.</p>
  
  <p>artifacts:
      expire_in: 1 week</p>
  
  <pre><code>build:buildjob
      paths:
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  
  test:testjob
        paths:
          - build/*.dmg
        artifacts:
          expire_in: 1 week
  </code></pre>
  
Answers: CC BY-SA 3.0
Answers: 2017-09-21T08:33:35.370Z
Answers: I forgot to mention in the question that I already have that defined in one job. My "build" job builds both the artifact as well as the "test" artifacts, however I don't want to cache the "test" artifacts as the cache doesn't get cleared after the pipeline.
Answers: Rekovni
Answers: CC BY-SA 3.0
Answers: 2017-09-20T21:47:53.027Z
Answers: 2017-09-20T21:47:53.027Z
Answers: Jakub Kania
Answers: <p>This has been answered over on <a href="https://stackoverflow.com/questions/46241987/multiple-paths-with-different-expiry-time-in-gitlab-ci-runners">SO</a> using a work around seeing as it doesn't seem possible according to the documents.</p>
  
  <p>Basically, this can be done in 3 stages.</p>
  
  <p><strong>Stage 1:</strong> Build and store all artifacts.</p>
  
  <pre><code>build_stage:
    script:
      - build
    artifacts:
      paths:
      - build/*.dmg
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  </code></pre>
  
  <p><strong>Stage 2.1:</strong> Do the next official stage of the job (ie run tests in my scenario) using the artifacts <code>build/test1, build/test2</code> and <code>build/test3</code>.</p>
  
  <pre><code>test_stage:
    script:
      - test
    dependencies:
    - build
  </code></pre>
  
  <p><strong>Stage 2.2:</strong> Running concurrently with Stage 2.1 you can just have an empty job but sets a new artifact expiry date.</p>
  
  <pre><code>overwrite_artifact_stage:
    script:
      - echo 'saving artifact'
    artifacts:
      paths:
      - build/*.dmg
      expire_in: 1 week
  </code></pre>
  
Answers: CC BY-SA 3.0
Answers: 2017-09-24T21:26:05.840Z
Answers: 2017-09-24T21:26:05.840Z
Answers: Rekovni
Body: <p>I'm having issues with parsing a <code>build</code> directory between stages using Gitlab-CI. </p>
  
  <p>Gitlab-CI wipes the created build artifacts between stages which seems weird. I'm trying to store the build artifacts between the build and the test stage, however the build stage also has the build artifact which I want to keep and also the build artifacts which are required to run the next stage.</p>
  
  <p>Is it possible to have multiple expiry times with different paths using the <code>artifacts</code> option? </p>
  
  <p>I have tried the following, which only keeps the second definition of <code>paths</code> (the build/test* paths), and not the first <code>paths</code> (.dmg) declared.</p>
  
  <pre><code>  artifacts:
      paths:
      - build/*.dmg
      expire_in: 1 week
      paths:
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  </code></pre>
  
  <p>I have tried using the <code>caches</code> however can't seem to get that working... Any suggestions would be great appreciated! </p>
  
Tags: <gitlab>
Title: Multiple paths with different expiry time in gitlab-ci runners
UserDisplayName: Rekovni
ThreadText: # Multiple paths with different expiry time in gitlab-ci runners
  
  (Asked by: username_0 on 2017-09-15)
  
  I'm having issues with parsing a `build` directory between stages using Gitlab-CI.
  
  Gitlab-CI wipes the created build artifacts between stages which seems weird. I'm trying to store the build artifacts between the build and the test stage, however the build stage also has the build artifact which I want to keep and also the build artifacts which are required to run the next stage.
  
  Is it possible to have multiple expiry times with different paths using the `artifacts` option?
  
  I have tried the following, which only keeps the second definition of `paths` (the build/test\* paths), and not the first `paths` (.dmg) declared.
  
  ```
    artifacts:
      paths:
      - build/*.dmg
      expire_in: 1 week
      paths:
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  
  ```
  
  I have tried using the `caches` however can't seem to get that working... Any suggestions would be great appreciated!
  
  **Tags:** gitlab
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-09-24. Score: 5 | Accepted answer
  
  This has been answered over on [SO](https://stackoverflow.com/questions/46241987/multiple-paths-with-different-expiry-time-in-gitlab-ci-runners) using a work around seeing as it doesn't seem possible according to the documents.
  
  Basically, this can be done in 3 stages.
  
  **Stage 1:** Build and store all artifacts.
  
  ```
  build_stage:
    script:
      - build
    artifacts:
      paths:
      - build/*.dmg
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  
  ```
  
  **Stage 2.1:** Do the next official stage of the job (ie run tests in my scenario) using the artifacts `build/test1, build/test2` and `build/test3`.
  
  ```
  test_stage:
    script:
      - test
    dependencies:
    - build
  
  ```
  
  **Stage 2.2:** Running concurrently with Stage 2.1 you can just have an empty job but sets a new artifact expiry date.
  
  ```
  overwrite_artifact_stage:
    script:
      - echo 'saving artifact'
    artifacts:
      paths:
      - build/*.dmg
      expire_in: 1 week
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2017-09-20. Score: 3
  
  It seems you're trying to define the artifacts globally, that won't work with multiple paths since you're overwriting the definition of the key. Instead you should define the paths per job.
  
  artifacts:
  expire\_in: 1 week
  
  ```
  build:buildjob
      paths:
      - build/test1
      - build/test2
      - build/test3
      expire_in: 15 mins
  
  test:testjob
        paths:
          - build/*.dmg
        artifacts:
          expire_in: 1 week
  
  ```
  
  > **Comments:**
  > **username_0**: I forgot to mention in the question that I already have that defined in one job. My "build" job builds both the artifact as well as the "test" artifacts, however I don't want to cache the "test" artifacts as the cache doesn't get cleared after the pipeline.  
  
  ---
  
  