Gitlab ci issue with passing artifacts to Downstream pipeline with trigger and needs keywords

Viewed 5882

I am working on a multi-pipeline project, and using trigger keyword to trigger a downstream pipeline, but I'm not able to pass artifacts created in the upstream project. I am using needs to get the artifact like so:

Downstream Pipeline block to get artifacts:

needs:
    - project: workspace/build
        job: build
        ref: master
        artifacts: true

Upstream Pipeline block to trigger:

build:
    stage: build
    artifacts:
    paths:
        - ./policies
    expire_in: 2h
    only:
    - master
    script:
    - echo 'Test'
    allow_failure: false

triggerUpstream:
    stage: deploy
    only:
    - master
    trigger:
    project: workspace/deploy

But I am getting the following error:

This job depends on other jobs with expired/erased artifacts:

I'm not sure what's wrong.

3 Answers

Looks like there is a problem sharing artifacts between pipelines as well as between projects. It is known bug and has been reported here:

https://gitlab.com/gitlab-org/gitlab/-/issues/228586

You can find a workaround there but since it needs to add access token to project it is not the best solution.

Your upstream pipeline job "Build" is set to only store its artifacts for 2 hours (from the expire_in: 2h line. Your downstream pipeline must have run at least 2 hours later than the artifacts were created, so the artifact expired and was erased, generating that error.

To solve it you can either update the expire_in field to however long you need them to be active (so for example if you know the downstream pipeline will run up to 5 days later, set it to 5d for 5 days), or rerun the Build job to recreate the artifacts.

You can read more about the expire_in keyword and artifacts in general from the docs

It isn't a problem with expired artifacts, the error is incorrect. In my case I am able to download the artifacts as a zip directly from the UI on the executed job. My expire_in is set to 1 week yet I am still getting this message.

Related