2020-03-10 02:08:07 -04:00
---
2020-05-29 14:08:26 -04:00
stage: Verify
2021-05-26 23:10:55 -04:00
group: Testing
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-03-13 17:09:38 -04:00
disqus_identifier: 'https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html'
2020-03-10 02:08:07 -04:00
type: reference, howto
---
2021-05-26 23:10:55 -04:00
# Job artifacts **(FREE)**
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
> Introduced in [GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/16675), artifacts in internal and private projects can be previewed when [GitLab Pages access control](../../administration/pages/index.md#access-control) is enabled.
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
Jobs can output an archive of files and directories. This output is known as a job artifact.
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
You can download job artifacts by using the GitLab UI or the [API ](../../api/job_artifacts.md#get-job-artifacts ).
2020-03-10 02:08:07 -04:00
< i class = "fa fa-youtube-play youtube" aria-hidden = "true" > < / i >
2021-04-20 05:09:48 -04:00
For an overview of job artifacts, watch the video [GitLab CI pipelines, artifacts, and environments ](https://www.youtube.com/watch?v=PCKDICEe10s ).
Or, for an introduction, watch [GitLab CI pipeline tutorial for beginners ](https://www.youtube.com/watch?v=Jav4vbUrqII ).
2020-03-10 02:08:07 -04:00
2021-04-20 05:09:48 -04:00
For administrator information about job artifact storage, see [administering job artifacts ](../../administration/job_artifacts.md ).
2021-04-09 08:09:12 -04:00
2021-04-20 05:09:48 -04:00
## Create job artifacts
2020-03-10 02:08:07 -04:00
2021-04-20 05:09:48 -04:00
To create job artifacts, use the `artifacts` keyword in your `.gitlab-ci.yml` file:
2020-03-10 02:08:07 -04:00
```yaml
pdf:
script: xelatex mycv.tex
artifacts:
paths:
2020-07-03 05:08:53 -04:00
- mycv.pdf
2020-03-10 02:08:07 -04:00
expire_in: 1 week
```
2021-04-20 05:09:48 -04:00
In this example, a job named `pdf` calls the `xelatex` command to build a PDF file from the
2021-03-24 23:09:35 -04:00
LaTeX source file, `mycv.tex` .
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
The `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.
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
The `expire_in` keyword determines how long GitLab keeps the job artifacts.
You can also [use the UI to keep job artifacts from expiring ](#download-job-artifacts ).
If `expire_in` is not defined, the
[instance-wide setting ](../../user/admin_area/settings/continuous_integration.md#default-artifacts-expiration )
is used.
2021-04-20 05:09:48 -04:00
If you run two types of pipelines (like branch and scheduled) for the same ref,
the pipeline that finishes later creates the job artifact.
2021-03-24 23:09:35 -04:00
For more examples, view the [keyword reference for the `.gitlab-ci.yml` file ](../yaml/README.md#artifacts ).
## Download job artifacts
You can download job artifacts or view the job archive:
- On the **Pipelines** page, to the right of the pipeline:
2021-04-20 05:09:48 -04:00
![Job artifacts in Pipelines page ](img/job_artifacts_pipelines_page_v13_11.png )
2021-03-24 23:09:35 -04:00
- On the **Jobs** page, to the right of the job:
2021-04-20 05:09:48 -04:00
![Job artifacts in Jobs page ](img/job_artifacts_jobs_page_v13_11.png )
2021-03-24 23:09:35 -04:00
- On a job's detail page. The **Keep** button indicates an `expire_in` value was set:
2021-04-20 05:09:48 -04:00
![Job artifacts browser button ](img/job_artifacts_browser_button_v13_11.png )
2021-03-24 23:09:35 -04:00
- On a merge request, by the pipeline details:
2021-04-20 05:09:48 -04:00
![Job artifacts in merge request ](img/job_artifacts_merge_request_v13_11.png )
2021-03-24 23:09:35 -04:00
- When browsing an archive:
2021-04-20 05:09:48 -04:00
![Job artifacts browser ](img/job_artifacts_browser_v13_11.png )
2021-03-24 23:09:35 -04:00
If [GitLab Pages ](../../administration/pages/index.md ) 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 ](../../administration/pages/index.md#access-control ) to preview
HTML files.
## View failed job artifacts
If the latest job has failed to upload the artifacts, you can see that
information in the UI.
![Latest artifacts button ](img/job_latest_artifacts_browser.png )
2021-04-20 05:09:48 -04:00
## Delete job artifacts
2021-03-24 23:09:35 -04:00
WARNING:
This is a destructive action that leads to data loss. Use with caution.
2021-04-20 05:09:48 -04:00
You can delete a single job, which also removes the job's
2021-03-24 23:09:35 -04:00
artifacts and log. You must be:
- The owner of the job.
2021-04-20 05:09:48 -04:00
- A [maintainer ](../../user/permissions.md#gitlab-cicd-permissions ) of the project.
2021-03-24 23:09:35 -04:00
2021-04-20 05:09:48 -04:00
To delete a job:
2021-03-24 23:09:35 -04:00
1. Go to a job's detail page.
1. At the top right of the job's log, select the trash icon.
1. Confirm the deletion.
2021-04-20 05:09:48 -04:00
## Retrieve job artifacts for other projects
2021-03-24 23:09:35 -04:00
To retrieve a job artifact from a different project, you might need to use a
private token to [authenticate and download ](../../api/job_artifacts.md#get-job-artifacts )
the artifact.
2021-04-20 05:09:48 -04:00
## How searching for job artifacts works
2021-03-24 23:09:35 -04:00
In [GitLab 13.5 ](https://gitlab.com/gitlab-org/gitlab/-/issues/201784 ) and later, artifacts
for [parent and child pipelines ](../parent_child_pipelines.md ) 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.
2021-04-20 05:09:48 -04:00
## Access the latest job artifacts by URL
2021-03-24 23:09:35 -04:00
2021-05-07 14:10:21 -04:00
You can download job artifacts from the latest successful pipeline by using a URL.
2021-03-24 23:09:35 -04:00
To download the whole artifacts archive:
```plaintext
https://example.com/< namespace > /< project > /-/jobs/artifacts/< ref > /download?job=< job_name >
```
To download a single file from the artifacts:
```plaintext
https://example.com/< namespace > /< project > /-/jobs/artifacts/< ref > /raw/< path_to_file > ?job=< job_name >
```
2021-04-20 05:09:48 -04:00
For example, to download the latest artifacts of the job named `coverage` in
the `main` branch of the `gitlab` project in the `gitlab-org`
2021-03-24 23:09:35 -04:00
namespace:
```plaintext
2021-04-20 05:09:48 -04:00
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/download?job=coverage
2021-03-24 23:09:35 -04:00
```
2021-05-27 05:10:32 -04:00
To download the file `review/index.html` from the same artifacts:
2021-03-24 23:09:35 -04:00
```plaintext
2021-05-27 05:10:32 -04:00
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/raw/review/index.html?job=coverage
2021-03-24 23:09:35 -04:00
```
To browse the latest job artifacts:
```plaintext
https://example.com/< namespace > /< project > /-/jobs/artifacts/< ref > /browse?job=< job_name >
```
For example:
```plaintext
2021-05-27 05:10:32 -04:00
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/browse?job=coverage
2021-03-24 23:09:35 -04:00
```
2021-04-20 05:09:48 -04:00
To download specific files, including HTML files that
2021-03-24 23:09:35 -04:00
are shown in [GitLab Pages ](../../administration/pages/index.md ):
```plaintext
https://example.com/< namespace > /< project > /-/jobs/artifacts/< ref > /file/< path > ?job=< job_name >
```
For example, when a job `coverage` creates the artifact `htmlcov/index.html` :
```plaintext
2021-05-27 05:10:32 -04:00
https://gitlab.com/gitlab-org/gitlab/-/jobs/artifacts/main/file/htmlcov/index.html?job=coverage
2021-03-24 23:09:35 -04:00
```
2021-04-20 05:09:48 -04:00
## When job artifacts are deleted
2021-05-05 23:10:25 -04:00
See the [`expire_in` ](../yaml/README.md#artifactsexpire_in ) documentation for information on when
job artifacts are deleted.
2021-04-20 05:09:48 -04:00
2021-03-24 23:09:35 -04:00
### Keep artifacts from most recent successful jobs
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/16267) in GitLab 13.0.
> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/229936) in GitLab 13.4.
> - [Made optional with a CI/CD setting](https://gitlab.com/gitlab-org/gitlab/-/issues/241026) in GitLab 13.8.
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:
1. Go to the project's **Settings > CI/CD > Artifacts** .
1. Clear the **Keep artifacts from most recent successful jobs** checkbox.
You can disable this behavior for all projects on a self-managed instance in the
[instance's CI/CD settings ](../../user/admin_area/settings/continuous_integration.md#keep-the-latest-artifacts-for-all-jobs-in-the-latest-successful-pipelines ).
When you disable the feature, the latest artifacts do not immediately expire.
A new pipeline must run before the latest artifacts can expire and be deleted.
2020-03-10 02:08:07 -04:00
2021-03-24 23:09:35 -04:00
## Troubleshooting job artifacts
2020-09-29 14:09:52 -04:00
### Error message `No files to upload`
2021-04-20 05:09:48 -04:00
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.
2020-09-29 14:09:52 -04:00
2021-04-20 05:09:48 -04:00
If you find no helpful messages, retry the failed job after activating
2021-02-16 13:09:24 -05:00
[CI/CD debug logging ](../variables/README.md#debug-logging ).
2021-04-20 05:09:48 -04:00
This logging should provide information to help you investigate further.