Guides / Keep files between runs
Verified against Flow 5.0.0-beta.39
Each run gets its own run workspace, which Flow removes when the run completes. To keep files for the next run, download them as a workflow-scoped artifact at the start of the workflow and upload them again at the end. This guide is for workflow authors.
ARTIFACTS_NOT_CONFIGURED. See Configuring.A workflow-scoped artifact belongs to the workflow, not to one run. Any later run of the workflow can download it by name, it never expires, and a later upload of the same name replaces it.
The pattern has three parts:
workflow and Optional on, restores the files. On the first run there's nothing to restore, and Optional lets the task succeed anyway.workflow, saves them for the next run.Both artifact tasks use the same Artifact name and the same path.
This example keeps a counter in /workspace/state/count and adds one on every run.
1./workspace.The artifact tasks read a relative path from /workspace. If you change Mount path, give them absolute paths under it instead.
Open the Canvas tab. From the Artifacts category, drag Download Artifact onto the canvas and select its edit icon.
Fill in Edit Download Artifact, then select Apply:
| Field | Value |
|---|---|
| Task name | restore-state |
| Artifact name | state |
| Destination path | state |
| Scope | workflow |
| Optional | On |
Leave the read-only fields, such as Download link, empty: Flow fills them in when the task runs.
From the Utilities category, drag Execute Shell onto the canvas and select its edit icon.
In Task name, enter count-runs.
Select Shell Script, enter the script below, and select Update:
mkdir -p /workspace/state
count=$(cat /workspace/state/count 2>/dev/null || echo 0)
count=$((count + 1))
echo "$count" > /workspace/state/count
echo "This workflow has run $count times"Select Apply.
From the Artifacts category, drag Upload Artifact onto the canvas and select its edit icon.
Fill in Edit Upload Artifact, then select Apply:
| Field | Value |
|---|---|
| Task name | save-state |
| Artifact name | state |
| Path | state |
| Scope | workflow |
Leave Retention days blank: a workflow-scoped upload can't set it.
Link the tasks in order: Start, restore-state, count-runs, save-state, End.

On the Workflows page, select Run it, then Run and View.
On this first run, restore-state finds no artifact and succeeds without downloading anything. Its found result is false.
When the run ends, run the workflow again the same way.
On the second run's page, select View Log on count-runs.
The log reads This workflow has run 2 times, and the run's status is Succeeded.
state is a folder, so Upload Artifact sends its contents as one .tar.gz, and Download Artifact unpacks them into the destination folder. A single file works the same way: give both tasks the file's path.
| Where | What it shows |
|---|---|
| Configure › Artifacts in the editor | This workflow's kept artifacts: Name (select it to download), Size, and Uploaded by with a View run link |
| Manage workspace › Artifacts | Every artifact in the workspace. Set Scope to Workflow to see only kept ones, which read Kept until replaced under Expires |
| The run page's Artifacts tab | The artifacts that run uploaded, each with Scope Workflow or Run |

To start again from nothing, delete the artifact: on its row in Configure › Artifacts, select Delete, then Delete in Are you sure?. The next run's Download Artifact task finds nothing, and with Optional on it succeeds. This can't be undone.
Two runs in flight at once both download the same artifact, and the upload that completes last wins: the other run's changes are lost. To keep updates in order, open Configure › Run Options, set Concurrency limit to 1, and leave Over the limit on Queue until a run ends.
ARTIFACT_ALREADY_EXISTS.., _ or -, up to 128 characters.ArtifactRefused. Flow never deletes another artifact to make room.ArtifactRefused.