Skip to main content
In this article, we’ll explore how artifacts capture and persist files produced during job execution in your GitLab CI/CD pipelines. You’ll learn how to configure artifacts in .gitlab-ci.yml, pass them between stages, and view them in the UI.

What Are Artifacts?

In GitLab CI/CD, artifacts are archives of files and directories generated by a job. They are:
  • Uploaded to GitLab when a job finishes.
  • Automatically downloaded by downstream jobs in the same pipeline.
  • Retained according to the expire_in policy you define.
Artifacts are uploaded only if the job’s status matches the when setting (e.g., on_success or always). Use the dependencies or needs keywords to control which upstream artifacts a job downloads.
The image shows a GitLab documentation page about CI/CD YAML syntax, specifically focusing on job artifacts and their configuration. The page includes navigation links on the left and a list of keywords on the right.

Configuring Artifacts

Under the artifacts section of a job, you can define several options. The table below summarizes the most common:

Example: Defining Artifacts

The image shows a GitLab documentation page about the artifacts:expire_in keyword, explaining how to specify the duration for storing job artifacts before they expire. It includes examples of valid time values and additional information on usage.

End-to-End Pipeline Example

Below is a simple three-stage pipeline where the build_job creates a file, then passes it to test_job and deploy_job.
With this setup:
  1. build_job generates dragon.txt and uploads it.
  2. test_job and deploy_job automatically download the artifact.
  3. Artifacts expire after three days.

Pipeline Execution and Logs

build_job

test_job

deploy_job

Viewing Artifacts in GitLab UI

In the Pipeline view, jobs that produce artifacts display an Artifacts badge. Clicking Browse or Download lets you inspect and retrieve the files.
The image shows a GitLab interface displaying a list of artifacts from different jobs, including their sizes and creation times. The sidebar includes navigation options like "Manage," "Plan," "Code," and "Build."
Artifacts also appear under the Artifacts tab on each job’s detail page, alongside logs and metadata.

References

Watch Video