GitLab CI "artifacts not found" / Expired Between Stages
By Kaveh Alemi·Latchkey
A later job expected files from an earlier one and found nothing. The upstream artifacts expired, were never declared, or the consuming job did not pull them in.
What this error means
A downstream job fails because expected build output is missing - "No such file or directory" for an artifact path, or the job log shows it downloaded no artifacts at all.
Job log
$ ./deploy.sh dist/app
./deploy.sh: line 3: dist/app: No such file or directory
# upstream artifacts expired or were never passed
Diagnose it: which rule matched, and on which runner?
GitLab evaluates rules: top to bottom and the first match wins, including one that sets when: never. A job that does not run, or runs when you did not expect it to, is nearly always matching an earlier rule than the one you are reading.
.gitlab-ci.yml
# validate the definition against the projectcurl -s --header "PRIVATE-TOKEN:$TOKEN" \"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/ci/lint" \--data-urlencode "content=$(cat .gitlab-ci.yml)"# what the job actually seesscript:- env | grep -E "^CI_(PIPELINE_SOURCE|COMMIT_REF_NAME|RUNNER)" | sort
Common causes
Artifacts expired before use
A short expire_in (or default expiry) removed the artifact before the consuming job ran - common when a pipeline is retried later.
Producer did not declare artifacts
The upstream job built the files but never declared artifacts:paths, so nothing was uploaded to pass downstream.
Consumer pulled the wrong dependencies
With dependencies: or needs:artifacts, the consuming job only receives artifacts from the listed jobs. An omitted or misnamed job yields no files.
How to fix it
Declare artifacts and keep them long enough
.gitlab-ci.yml
build:stage:buildscript:makeartifacts:paths:[dist/]expire_in:1 day
Pull the right artifacts downstream
Name the producing job so the consumer actually receives its artifacts.
Set expire_in longer than your retry window for artifacts you depend on.
Always declare artifacts:paths on jobs whose output is consumed later.
Use needs:artifacts / dependencies to pass exactly the right outputs.
Frequently asked questions
What causes GitLab CI "artifacts not found" / expired between stages?
There are 3 common causes: artifacts expired before use, producer did not declare artifacts, and consumer pulled the wrong dependencies. A short expire_in (or default expiry) removed the artifact before the consuming job ran - common when a pipeline is retried later.
How do I fix GitLab CI "artifacts not found" / expired between stages?
There are 2 fixes depending on which cause you have: declare artifacts and keep them long enough and pull the right artifacts downstream. Work through them in order, since the first is the most common.
What does GitLab CI "artifacts not found" / expired between stages actually mean?
A downstream job fails because expected build output is missing - "No such file or directory" for an artifact path, or the job log shows it downloaded no artifacts at all.
How do I stop GitLab CI "artifacts not found" / expired between stages happening again?
Set expire_in longer than your retry window for artifacts you depend on. The prevention section lists 3 changes that keep it from recurring.