# uip tm attachment

> `uip tm attachment` downloads the files captured by the test case logs in a test execution — screenshots, serialized state, recorded logs, any file the automation attached to a log. Use it after a run to pull evidence into your CI workspace, usually alongside a JUnit report from [`uip tm result download`](./uip-test-manager-result.md).

`uip tm attachment` downloads the files captured by the test case logs in a test execution — screenshots, serialized state, recorded logs, any file the automation attached to a log. Use it after a run to pull evidence into your CI workspace, usually alongside a JUnit report from [`uip tm result download`](./uip-test-manager-result.md).

## Synopsis

```
uip tm attachment download --execution-id <uuid> (--project-key <key> | --test-set-key <key>)
                           [--test-case-name <name>]… [--only-failed] [--result-path <path>]
```

All verbs honor the [global options](./global-options.md) and the standard [exit codes](./exit-codes.md). Every verb accepts `-t, --tenant <name>` and `--log-level <level>` (default `Information`).

## uip tm attachment download

Download attachments for the test case logs of a single execution. The command pages through the logs, optionally narrows to failed-only or to named test cases, then lists and downloads every attachment into a per-test-case subdirectory under `--result-path`. Failures on individual attachments are logged and recorded in a `Skipped` field; they do not abort the overall run.

### Arguments

None.

### Options

- `--execution-id <uuid>` *(required)* — execution whose attachments to pull.
- `--project-key <key>` — owning project. Either this or `--test-set-key` is required.
- `--test-set-key <key>` — test set key (e.g. `DEMO:42`); the project key is derived from the prefix.
- `--test-case-name <name>` — filter by test case name (case-insensitive substring). Can be **repeated** to accept any of several names. Matching is against the package entry point name, falling back to the test case name and the automation test case name.
- `--only-failed` — download attachments only for test case logs with result `Failed`.
- `--result-path <path>` — output directory. Defaults to the current working directory (`.`). The directory is created if missing.

### Layout on disk

```
<result-path>/
  <sanitized test case name>/
    <sanitized attachment file name>
    <sanitized attachment file name>
  <sanitized test case name>/
    <sanitized attachment file name>
```

File and directory names are sanitized — characters that are illegal on Windows or Unix (`< > : " / \ | ? *` and control characters) are replaced with `_`, and names are truncated to 200 characters.

### Examples

```bash
# download everything
uip tm attachment download \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO \
  --result-path ./attachments

# only failed tests, narrowed to two named cases
uip tm attachment download \
  --execution-id a1b2c3d4-0000-0000-0000-000000000001 \
  --project-key DEMO \
  --only-failed \
  --test-case-name login \
  --test-case-name checkout \
  --result-path ./attachments
```

### Data shape

Normal run:

```json
{
  "Code": "AttachmentDownload",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "OutputPath": "./attachments",
    "Downloaded": 3,
    "MatchedTestCases": 2
  }
}
```

When no test case log matches the filters:

```json
{
  "Code": "AttachmentDownload",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "Message": "No matching test case logs found.",
    "Downloaded": 0
  }
}
```

When some attachments fail to list or download, a `Skipped` array is appended with one entry per failure, formatted `"<test case name>: <error message>"`:

```json
{
  "Code": "AttachmentDownload",
  "Data": {
    "ExecutionId": "a1b2c3d4-0000-0000-0000-000000000001",
    "OutputPath": "./attachments",
    "Downloaded": 2,
    "MatchedTestCases": 3,
    "Skipped": ["Login flow: HTTP 404: Not Found"]
  }
}
```

## Related

- [testsets run](./uip-test-manager-testsets.md#uip-tm-testsets-run) — produces the `ExecutionId` consumed here.
- [wait](./uip-test-manager-wait.md) — block until the execution is terminal before pulling attachments.
- [result](./uip-test-manager-result.md) — JUnit XML of the same execution.
- [report](./uip-test-manager-report.md) — human-readable summary.

## See also

- [Test Manager overview](./uip-test-manager.md)
- [Scripting patterns](./scripting-patterns.md)
