HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Multiple paths with different expiry time in gitlab-ci runners

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
runnerswithgitlabexpirypathstimedifferentmultiple

Problem

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!

Solution

This has been answered over on SO 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

Code Snippets

build_stage:
  script:
    - build
  artifacts:
    paths:
    - build/*.dmg
    - build/test1
    - build/test2
    - build/test3
    expire_in: 15 mins
test_stage:
  script:
    - test
  dependencies:
  - build
overwrite_artifact_stage:
  script:
    - echo 'saving artifact'
  artifacts:
    paths:
    - build/*.dmg
    expire_in: 1 week

Context

StackExchange DevOps Q#2019, answer score: 5

Revisions (0)

No revisions yet.