- Create job artifacts
- Download job artifacts
- View failed job artifacts
- Delete job artifacts
- Expose job artifacts in the merge request UI
- Retrieve job artifacts for other projects
- How searching for job artifacts works
- Access the latest job artifacts by URL
- When job artifacts are deleted
- Troubleshooting job artifacts
Job artifacts
Jobs can output an archive of files and directories. This output is known as a job artifact.
You can download job artifacts by using the GitLab UI or the API.
For an overview of job artifacts, watch the video GitLab CI pipelines, artifacts, and environments.
Or, for an introduction, watch GitLab CI pipeline tutorial for beginners.
For administrator information about job artifact storage, see administering job artifacts.
To create job artifacts, use the In this example, a job named The The If you run two types of pipelines (like branch and scheduled) for the same ref,
the pipeline that finishes later creates the job artifact.
To disable artifact passing, define the job with empty dependencies:
You may want to create artifacts only for tagged releases to avoid filling the
build server storage with temporary build artifacts. For example, use You can use wildcards for directories too. For example, if you want to get all the
files inside the directories that end with You can use CI/CD variables to dynamically define the
artifacts file’s name.
For example, to create an archive with a name of the current job:
To create an archive with a name of the current branch or tag including only
the binaries directory:
If your branch-name contains forward slashes
(for example To create an archive with a name of the current job and the current branch or
tag including only the binaries directory:
To create an archive with a name of the current stage and branch name:
If you use Windows Batch to run your shell scripts you must replace
If you use Windows PowerShell to run your shell scripts you must replace
Use For example, to store all files in Unlike For example, to store all files in Use Save all Git untracked files and files in Save all untracked files but exclude You can download job artifacts or view the job archive:
On the Pipelines page, to the right of the pipeline:
On the Jobs page, to the right of the job:
On a job’s detail page. The Keep button indicates an On a merge request, by the pipeline details:
When browsing an archive:
If GitLab Pages is enabled in the project, you can preview
HTML files in the artifacts directly in your browser. If the project is internal or private, you must
enable GitLab Pages access control to preview
HTML files.
If the latest job has failed to upload the artifacts, you can see that
information in the UI.
You can delete a single job, which also removes the job’s
artifacts and log. You must be:
To delete a job:
Use the For example, to match a single file:
With this configuration, GitLab adds a link artifact 1 to the relevant merge request
that points to An example that matches an entire directory:
To retrieve a job artifact from a different project, you might need to use a
private token to authenticate and download
the artifact.
In parent and child pipelines are searched in hierarchical
order from parent to child. For example, if both parent and child pipelines have a
job with the same name, the job artifact from the parent pipeline is returned.
You can download job artifacts from the latest successful pipeline by using a URL.
To download the whole artifacts archive:
To download a single file from the artifacts:
For example, to download the latest artifacts of the job named To download the file To browse the latest job artifacts:
For example:
To download specific files, including HTML files that
are shown in GitLab Pages:
For example, when a job See the By default artifacts are always kept for the most recent successful pipeline for
each ref. This means that the latest artifacts do not immediately expire according
to the If a new pipeline for the same ref completes successfully, the previous pipeline’s
artifacts are deleted according to the Keeping the latest artifacts can use a large amount of storage space in projects
with a lot of jobs or large artifacts. If the latest artifacts are not needed in
a project, you can disable this behavior to save space:
You can disable this behavior for all projects on a self-managed instance in the
instance’s CI/CD settings.
This message is often preceded by other errors or warnings that specify the filename and why it wasn’t
generated. Check the job log for these messages.
If you find no helpful messages, retry the failed job after activating
CI/CD debug logging.
This logging should provide information to help you investigate further.
Create job artifacts
artifacts
keyword in your .gitlab-ci.yml
file:
pdf:
script: xelatex mycv.tex
artifacts:
paths:
- mycv.pdf
expire_in: 1 week
pdf
calls the xelatex
command to build a PDF file from the
LaTeX source file, mycv.tex
.
paths
keyword determines which files to add to the job artifacts.
All paths to files and directories are relative to the repository where the job was created.
expire_in
keyword determines how long GitLab keeps the job artifacts.
You can also use the UI to keep job artifacts from expiring.
If expire_in
is not defined, the
instance-wide setting
is used.
job:
stage: build
script: make build
dependencies: []
rules
to create artifacts only for tags:
default-job:
script:
- mvn test -U
rules:
- if: $CI_COMMIT_BRANCH
release-job:
script:
- mvn package -U
artifacts:
paths:
- target/*.war
rules:
- if: $CI_COMMIT_TAG
xyz
:
job:
artifacts:
paths:
- path/*xyz/*
Use CI/CD variables to define the artifacts name
job:
artifacts:
name: "$CI_JOB_NAME"
paths:
- binaries/
job:
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- binaries/
feature/my-feature
) it’s advised to use $CI_COMMIT_REF_SLUG
instead of $CI_COMMIT_REF_NAME
for proper naming of the artifact.
job:
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- binaries/
job:
artifacts:
name: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"
paths:
- binaries/
$
with %
:
job:
artifacts:
name: "%CI_JOB_STAGE%-%CI_COMMIT_REF_NAME%"
paths:
- binaries/
$
with $env:
:
job:
artifacts:
name: "$env:CI_JOB_STAGE-$env:CI_COMMIT_REF_NAME"
paths:
- binaries/
Exclude files from job artifacts
artifacts:exclude
to prevent files from
being added to an artifacts archive.
binaries/
, but not *.o
files located in
subdirectories of binaries/
.
artifacts:
paths:
- binaries/
exclude:
- binaries/**/*.o
artifacts:paths
, exclude
paths are not recursive.
To exclude all of the contents of a directory, match them explicitly rather
than matching the directory itself.
binaries/
but nothing located in the temp/
subdirectory:
artifacts:
paths:
- binaries/
exclude:
- binaries/temp/**/*
Add untracked files to artifacts
artifacts:untracked
to add all Git untracked
files as artifacts (along with the paths defined in artifacts:paths
). Untracked
files are those that haven’t been added to the repository but exist in the repository checkout.
binaries
:
artifacts:
untracked: true
paths:
- binaries/
*.txt
:
artifacts:
untracked: true
exclude:
- "*.txt"
Download job artifacts
expire_in
value was set:
View failed job artifacts
Delete job artifacts
Expose job artifacts in the merge request UI
artifacts:expose_as
keyword to expose
job artifacts in the merge request UI.
test:
script: ["echo 'test' > file.txt"]
artifacts:
expose_as: 'artifact 1'
paths: ['file.txt']
file.txt
. To access the link, select View exposed artifact
below the pipeline graph in the merge request overview.
test:
script: ["mkdir test && echo 'test' > test/file.txt"]
artifacts:
expose_as: 'artifact 1'
paths: ['test/']
Retrieve job artifacts for other projects
How searching for job artifacts works
Access the latest job artifacts by URL
https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/download?job=<job_name>
https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>
coverage
in
the main
branch of the gitlab
project in the gitlab-org
namespace:
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/download?job=coverage
review/index.html
from the same artifacts:
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/raw/review/index.html?job=coverage
https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/browse?job=<job_name>
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/browse?job=coverage
https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/file/<path>?job=<job_name>
coverage
creates the artifact htmlcov/index.html
:
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/file/htmlcov/index.html?job=coverage
When job artifacts are deleted
expire_in
documentation for information on when
job artifacts are deleted.
Keep artifacts from most recent successful jobs
expire_in
specification.
expire_in
configuration. The artifacts
of the new pipeline are kept automatically.
Troubleshooting job artifacts
Error message
No files to upload
Error message
Missing /usr/bin/gitlab-runner-helper. Uploading artifacts is disabled.