6

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!

5

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
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
  • 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. – Rekovni Sep 21 '17 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.