# Artifacts

<!-- Generated by tools/catalogue/generate.py from flow.service.workflow 5.0.0-beta.39. Don't edit by hand. -->

# Artifacts

The Artifacts category has 2 tasks. Each entry shows the task's latest revision, the one the palette adds. See [Reading an entry](https://www.useboomerang.io/docs/flow/main/catalogue/overview#reading-an-entry).

## Download Artifact

Download an artifact of this run, or the workflow's kept artifact of that name, into the run workspace, checking its SHA-256.

- **Slug:** `download-artifact`
- **Type:** `downloadartifact`
- **Revision:** 1
- **Image:** The image in the dispatcher's `flow.dispatcher.artifact.image` property, `boomerangio/task-flow:3.3.0` by default.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Artifact name | `name` | Text | Yes |  | An artifact an earlier task in this run uploaded, or with scope workflow the workflow's kept artifact of that name. |
| Destination path | `path` | Text | Yes |  | Where to put it; an uploaded folder is unpacked here. Relative to /workspace (e.g. workflowrun/inputs/), or an absolute path. |
| Scope | `scope` | Select | No | `run` | run: this run only, expires on its retention date. workflow: kept for every later run of this workflow until replaced. |
| Optional | `optional` | Boolean | No | `false` | Succeed with result found=false when no artifact of this name exists, instead of failing. |
| Download link | `url` | Secured, read-only | No |  | Filled in by Flow when the task runs. |
| Download headers | `headers` | Text, read-only | No |  | Filled in by Flow when the task runs. |
| SHA-256 | `sha256` | Text, read-only | No |  | Filled in by Flow when the task runs. |
| Content type | `contentType` | Text, read-only | No |  | Filled in by Flow when the task runs. |

**Results**

| Name | Description |
| --- | --- |
| `found` | true when an artifact was downloaded |

### Example

At the start of each run, restore the folder that the last run saved as `state`, and carry on when there's nothing to restore yet. This is the `restore-state` task in [Keep files between runs](https://www.useboomerang.io/docs/flow/main/guides/keep-files-between-runs).

| Field | Value |
| --- | --- |
| **Task name** | `restore-state` |
| **Artifact name** | `state` |
| **Destination path** | `state`, which resolves to `/workspace/state` |
| **Scope** | `workflow` |
| **Optional** | On |
| **Download link**, **Download headers**, **SHA-256**, **Content type** | Empty: Flow fills them in when the task runs |

The task returns:

| Result | Value |
| --- | --- |
| `found` | `false` on the first run, and `true` once a run has uploaded `state` |

The task checks the download's SHA-256 and unpacks the folder into `/workspace/state`. A later task can read `$(tasks.restore-state.results.found)` to tell a first run from the rest.

### Common problems

| Symptom | Cause | Fix |
| --- | --- | --- |
| The task fails with `ArtifactRefused` | No artifact of that name exists in that scope, and **Optional** is off. | Check **Artifact name** and **Scope**, or turn on **Optional** so a first run carries on. |
| `found` is `false` on every run | The upload doesn't match: it uses another **Artifact name**, or scope `run`, the default, which a later run can't see. | Use the same name, and scope `workflow`, on both tasks. |
| The task fails with `ARTIFACTS_NOT_CONFIGURED` | Flow has no artifact store connected. | Ask your operator to connect one. See [Connect the artifact store](https://www.useboomerang.io/docs/flow/main/hosting/configuring#connect-the-artifact-store). |

## Upload Artifact

Upload a file or folder from the run workspace as an artifact of this run or of the workflow.

- **Slug:** `upload-artifact`
- **Type:** `uploadartifact`
- **Revision:** 1
- **Image:** The image in the dispatcher's `flow.dispatcher.artifact.image` property, `boomerangio/task-flow:3.3.0` by default.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Artifact name | `name` | Text | Yes |  | Unique within the run. Letters, digits, dot, dash and underscore. |
| Path | `path` | Text | Yes |  | A file or folder to upload; a folder is sent as one .tar.gz. Relative to /workspace (e.g. workflowrun/reports/sbom.json), or an absolute path. |
| Scope | `scope` | Select | No | `run` | run: this run only, expires on its retention date. workflow: kept for every later run of this workflow until replaced. |
| Retention days | `retention-days` | Text | No |  | Blank keeps it for the workspace's retention. You can ask for fewer days, not more. Not allowed with scope workflow. |
| Upload link | `url` | Secured, read-only | No |  | Filled in by Flow when the task runs. |
| Upload headers | `headers` | Text, read-only | No |  | Filled in by Flow when the task runs. |

No results.

### Example

At the end of each run, save the folder `/workspace/state` for the next run of the workflow, with **Shared workspace for each run** on. This is the `save-state` task in [Keep files between runs](https://www.useboomerang.io/docs/flow/main/guides/keep-files-between-runs).

| Field | Value |
| --- | --- |
| **Task name** | `save-state` |
| **Artifact name** | `state` |
| **Path** | `state`, which resolves to `/workspace/state` |
| **Scope** | `workflow` |
| **Retention days** | Blank: an upload with scope `workflow` can't set it |
| **Upload link**, **Upload headers** | Empty: Flow fills them in when the task runs |

`state` is a folder, so the task uploads its contents as one `.tar.gz`. The artifact is listed under **Configure › Artifacts**, and is kept until a later upload of the same name replaces it. A Download Artifact task with the same name and scope restores it. The task returns no results.

### Common problems

| Symptom | Cause | Fix |
| --- | --- | --- |
| The task fails with `Path does not exist: /workspace/state` | Nothing is at that path: the run workspace is off, an earlier task wrote somewhere else, or **Mount path** isn't `/workspace`. | Turn on **Shared workspace for each run**. If you changed **Mount path**, give an absolute path under it. |
| The task fails with `ARTIFACT_ALREADY_EXISTS` | An upload of that name already ran in this run, for example in an earlier for-each item. | Give each upload in a run its own **Artifact name**. |
| The task fails with `ARTIFACT_INVALID_SCOPE` | **Retention days** is set on an upload with scope `workflow`. | Leave **Retention days** blank for a workflow-scoped upload. |
| The task fails with `ArtifactRefused` | The file is larger than **Admin › Settings › Artifacts › Largest Artifact (MB)**, 1024 MB by default, or would take the workspace over its artifact storage quota. | Upload less, delete artifacts you no longer need, or ask an admin to raise the limit. |
