Skip to main content

Gitlab : Download artifacts from a job in another child pipeline

I want to download an Artifact in a job present in a Child pipeline from another job present in another Child pipeline part of the same parent-child pipeline hierarchy.

I tried with the files below that are inspired from the Gitlab documentation (see the paragraph "Example of needs:pipeline:job" in https://docs.gitlab.com/ee/ci/yaml/) but with no success (I have this error : This job depends on other jobs with expired/erased artifacts)

parent.yml

parent1:
  stage: test
  trigger:
    include: child1.yml
    strategy: depend

parent2:
  stage: test
  trigger:
    include: child2.yml
    strategy: depend
  variables:
    PARENT_PIPELINE_ID: $CI_PIPELINE_ID

Child1.yml

create-artifact:
  stage: build
  script: echo "sample artifact" > artifact.txt
  artifacts:
    paths: [artifact.txt]

Child2.yml

use-artifact:
  script: cat artifact.txt
  needs:
    - pipeline: $PARENT_PIPELINE_ID
      job: create-artifact

So according to the official Gitlab documentation : A child pipeline can download artifacts from a job in its parent pipeline or another child pipeline in the same parent-child pipeline hierarchy. so I am wondering how to make it work in my example files?

AmineDg
  • 51
  • 1
  • 2