From a7cc28b5770ab1df1da29a17aef26b4a4390558b Mon Sep 17 00:00:00 2001 From: finalerock44 Date: Wed, 18 Nov 2026 16:15:02 +0000 Subject: [PATCH] docs(artifacts): per-flow downloads, step hierarchies and screenshots - dcd artifacts: the new --result-id and --flow flags, with examples. A failed or incomplete download now exits 1 with or without --json. - Artifacts: each failed or warned step's screen hierarchy and screenshot (Maestro 2.7+), how to match them to commands.json by step number, and what a one-flow download contains. - REST API and OpenAPI spec: the optional resultId body field on POST /results/{uploadId}/download, with its 400 and 404. - MCP: resultId and flow on dcd_download_artifacts. - Environment variables: screen hierarchies are masked like commands.json. Held until the API and CLI changes are released. --- api/results.md | 11 +++++++ artifacts/artifacts.md | 22 +++++++++++++- cli/dcd-artifacts.md | 14 ++++++++- configuration/environment-variables.md | 2 +- mcp/tools.md | 2 ++ public/openapi.yaml | 40 +++++++++++++++++++++----- 6 files changed, 81 insertions(+), 10 deletions(-) diff --git a/api/results.md b/api/results.md index facbcf1..cd643c0 100644 --- a/api/results.md +++ b/api/results.md @@ -164,6 +164,7 @@ POST /results/:uploadId/download | Field | Values | Description | |-------|--------|-------------| | `results` | `FAILED`, `ALL` | Which test artifacts to include. | +| `resultId` | A result ID (optional) | Only the files of the flow run this result belongs to: its first attempt and every retry, on that one device. `report.xml` then covers just that run. Use the `id` of a result from [Get results](#get-results). A value that isn't a positive whole number is a `400`, and a result that isn't in this upload is a `404`. | **Example** @@ -174,3 +175,13 @@ curl -X POST https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f -d '{"results": "FAILED"}' \ -o artifacts.zip ``` + +To download one flow run only, add its result ID: + +```bash +curl -X POST https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f1d12a/download \ + -H "x-app-api-key: " \ + -H "Content-Type: application/json" \ + -d '{"results": "ALL", "resultId": 4446290}' \ + -o artifacts.zip +``` diff --git a/artifacts/artifacts.md b/artifacts/artifacts.md index b5bf74c..bc39315 100644 --- a/artifacts/artifacts.md +++ b/artifacts/artifacts.md @@ -8,6 +8,7 @@ Each test run generates: * Logs * Screenshots, including the diff image from every [`assertScreenshot`](../advanced/visual-testing.md#reading-a-failure) that doesn't match, whether it failed the flow or was `optional: true` and only warned +* A screenshot and a screen hierarchy (the on-screen element tree, as JSON) for each step that failed or warned, on Maestro 2.7 and later * Videos * Test reports @@ -38,6 +39,9 @@ Use the [`dcd artifacts`](../cli/dcd-artifacts.md) command to download artifacts # Download a zip of all artifacts dcd artifacts --upload-id --download-artifacts ALL +# Download one flow's artifacts only +dcd artifacts --upload-id --download-artifacts ALL --flow login + # Download a JUnit report dcd artifacts --upload-id --report junit @@ -63,9 +67,12 @@ artifacts.zip │ ├── logs/ │ │ ├── login-maestro.log │ │ ├── login-commands.json +│ │ ├── login-step-004-tapOn.json +│ │ ├── login-step-009-tapOn.json │ │ └── ... │ ├── screenshots/ │ │ ├── login-failure-screenshot.jpg +│ │ ├── login-step-004-tapOn.jpg │ │ └── login-diff-screenshots-home_diff.png │ └── videos/ │ └── login-recording.mp4 @@ -73,11 +80,24 @@ artifacts.zip │ ├── logs/ │ ├── screenshots/ │ └── videos/ -└── report.xml # merged JUnit report covering every test in the upload +└── report.xml # merged JUnit report covering every test in the download ``` Files are named after the flow file (without its extension), e.g. `login-maestro.log` for `login.yaml`. In `screenshots/`, a failed flow has one `-failure-screenshot.jpg` of the whole screen, each `takeScreenshot` is named after its `path` (`login-home.jpg` for `takeScreenshot: home`), and each `assertScreenshot` diff is named after its baseline (see [Reading a failure](../advanced/visual-testing.md#reading-a-failure)). Screenshots taller than 1080 px are downscaled to 1080 px tall and saved as JPEG; smaller ones, such as a crop made with `cropOn`, keep their size. Diffs are always full-size PNGs. The `logs/` folder also holds stdout/stderr, the device log (`-logcat.zip` on Android, `-ios-device-log.zip` on iOS) and any per-flow reports. With `--download-artifacts FAILED`, only failed tests get a folder, but `report.xml` is always included and still covers every test. +### Step screenshots and screen hierarchies + +On Maestro 2.7 and later, each step that failed or warned (an `optional: true` step that didn't succeed) also has: + +* its screen hierarchy in `logs/`, named `-step--.json` +* its screenshot in `screenshots/`, named `-step--.jpg` + +The flow's `commands.json` lists these as `SCREEN_HIERARCHY` and `SCREENSHOT` artifacts at the paths Maestro wrote them to, such as `screen-hierarchy/step-009-tapOn.json` and `screenshots/step-009-tapOn.png`. To find a step's files in the archive, match on the `step-` number. Two differences from those paths: screenshots are saved as JPEG like every other screenshot, and the step that failed the flow keeps its screenshot under the usual `-failure-screenshot.jpg` name. Secret-named variables are masked in screen hierarchies as they are in `commands.json`, within the limits in [Environment Variables](../configuration/environment-variables.md). + +### One flow at a time + +`--flow` or `--result-id` narrows the download to one flow on one device: its first attempt and every retry, each in its own result-ID folder. `report.xml` then covers just that flow. See the [`dcd artifacts` reference](../cli/dcd-artifacts.md) for how `--flow` matches a flow. + Each [retry](../advanced/retry-strategies.md#seeing-every-attempt) attempt gets its own result-ID folder, so the failed attempt's screenshots and video are in the zip even if a retry passed. ## Report formats diff --git a/cli/dcd-artifacts.md b/cli/dcd-artifacts.md index 70b9bdc..9c6f94f 100644 --- a/cli/dcd-artifacts.md +++ b/cli/dcd-artifacts.md @@ -29,6 +29,8 @@ Pass exactly one of `--download-artifacts` or `--report`. |------|-------------| | `--download-artifacts ` | Download a zip of logs, screenshots, and videos. `ALL` includes every test; `FAILED` includes only failed tests. Mutually exclusive with `--report` | | `--artifacts-path ` | Output path for the artifacts zip (default: `./artifacts.zip`). Requires `--download-artifacts` | +| `--result-id ` | Download only one result's artifacts: that flow's first attempt and every retry, on that one device. Requires `--download-artifacts`. Mutually exclusive with `--flow` | +| `--flow ` | Download only one flow's artifacts, by its file path (`flows/login.yaml`), file name (`login.yaml`) or name (`login`). If it matches more than one result, for example one per device in a [device matrix](../configuration/device-matrix.md), the command fails and lists the result IDs to pass to `--result-id`. Requires `--download-artifacts`. Mutually exclusive with `--result-id` | ### Report Download @@ -46,7 +48,7 @@ Pass exactly one of `--download-artifacts` or `--report`. | `--json` | Print the result as one JSON object: `status` (`SUCCESS` or `FAILED`), `uploadId`, and `downloads`, with one entry per file giving its `type`, `path`, `ok` and, if it failed, `error` | | `--debug` | Enable detailed debug logging | -A download that fails prints a warning, and the command still exits `0`. With `--json`, it exits `1` when every download failed. +A download that fails prints a warning, and the command exits `1`, with or without `--json`. Every ZIP download is checked for completeness: if a download ends early, the command retries it once through a slower route, and if that one is also incomplete, it deletes the partial file and fails. ## Examples @@ -60,6 +62,16 @@ dcd artifacts --upload-id 123e4567-e89b-12d3-a456-426614174000 --download-artifa dcd artifacts --upload-id 123e4567-e89b-12d3-a456-426614174000 --download-artifacts FAILED --artifacts-path ./failed-artifacts.zip ``` +**Download artifacts for one flow:** +```bash +dcd artifacts --upload-id 123e4567-e89b-12d3-a456-426614174000 --download-artifacts ALL --flow login +``` + +**Download artifacts for one result, for example one device of a matrix:** +```bash +dcd artifacts --upload-id 123e4567-e89b-12d3-a456-426614174000 --download-artifacts ALL --result-id 4446290 +``` + **Download a JUnit report:** ```bash dcd artifacts --upload-id 123e4567-e89b-12d3-a456-426614174000 --report junit diff --git a/configuration/environment-variables.md b/configuration/environment-variables.md index 12bce81..4d40134 100644 --- a/configuration/environment-variables.md +++ b/configuration/environment-variables.md @@ -82,7 +82,7 @@ Variables whose names start with `MAESTRO_` are also set in the environment of t ## Masking Secrets -Values of variables whose names contain a keyword such as `PASSWORD`, `TOKEN`, `SECRET` or `API_KEY` are masked in the result log and in the downloadable `maestro.log`, stdout/stderr and `commands.json` — see [Inspecting Variables](../artifacts/inspecting-variables.md) for the full list of keywords. Masking has limits: +Values of variables whose names contain a keyword such as `PASSWORD`, `TOKEN`, `SECRET` or `API_KEY` are masked in the result log and in the downloadable `maestro.log`, stdout/stderr, `commands.json` and step screen hierarchies — see [Inspecting Variables](../artifacts/inspecting-variables.md) for the full list of keywords. Masking has limits: - Values passed with `--env` / `-e` are only masked if they're 5 or more characters long, so a short value such as a 4-digit PIN stays visible. - Literal values assigned in a script, such as `password = '...'`, are masked. Values written directly in a flow's `env:` block, and values computed at runtime (`output.*`), are not. diff --git a/mcp/tools.md b/mcp/tools.md index c776958..a272fa5 100644 --- a/mcp/tools.md +++ b/mcp/tools.md @@ -52,6 +52,8 @@ Download a completed run's artifacts zip (videos, logs and screenshots) to local | `uploadId` | string | **Required.** UUID of the upload to download artifacts for | | `type` | `ALL` \| `FAILED` | Which tests to include artifacts for (default `ALL`) | | `artifactsPath` | string | Where to write the artifacts zip (default `./artifacts.zip`). A relative path is from the server's working directory, which your MCP client chooses, so prefer an absolute path | +| `resultId` | integer | Only this result's artifacts: its flow's first attempt and every retry, on that one device. Can't be combined with `flow` | +| `flow` | string | Only this flow's artifacts, by its file path (`flows/login.yaml`), file name or name (`login`). When it matches several results, for example one per device, the download fails with a warning that lists their IDs to pass as `resultId`. Can't be combined with `resultId` | | `report` | `junit` \| `allure` \| `html` | Also download a formatted report of this type. `allure` is deprecated, see [Deprecations & Removals](../getting-started/deprecations.md) | | `reportPath` | string | Where to write the report (defaults by type: `report.xml` for `junit`, `report.zip` for `html`, `report.html` for `allure`). The `html` report is a ZIP. A relative path works as for `artifactsPath` | diff --git a/public/openapi.yaml b/public/openapi.yaml index d96e186..4e0ce5e 100644 --- a/public/openapi.yaml +++ b/public/openapi.yaml @@ -469,6 +469,9 @@ paths: for the whole upload is at the root. Every attempt's files are included, so a retried test's failed attempt can still be debugged. + Pass `resultId` to get one flow run only: that result's first attempt and + every retry, on its one device. `report.xml` then covers just that run. + The ZIP is streamed as it is built. An error after streaming starts ends the download early, leaving a truncated ZIP. parameters: @@ -496,16 +499,25 @@ paths: contentMediaType: application/zip '400': description: | - `uploadId` isn't a UUID (JSON), or the ZIP couldn't be assembled (the - message as plain text). + `uploadId` isn't a UUID or `resultId` isn't a positive whole number + (JSON), or the ZIP couldn't be assembled (the message as plain text). content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' - example: - statusCode: 400 - message: Validation failed (uuid is expected) - error: Bad Request + examples: + badUploadId: + summary: uploadId isn't a UUID + value: + statusCode: 400 + message: Validation failed (uuid is expected) + error: Bad Request + badResultId: + summary: resultId isn't a positive whole number + value: + statusCode: 400 + message: resultId must be a positive whole number + error: Bad Request text/plain: schema: type: string @@ -516,7 +528,7 @@ paths: The upload has no results in your team, or doesn't exist. Unlike the report downloads, this one answers with the standard error envelope. For a key with **CI: run tests only** access, also a run that key didn't - start. + start. With `resultId`, also a result that isn't in this upload. content: application/json: schema: @@ -534,6 +546,12 @@ paths: statusCode: 404 message: Upload not found error: UPLOAD_NOT_FOUND + resultNotInUpload: + summary: A resultId from another upload + value: + statusCode: 404 + message: Result 4446290 not found in upload 7e12345f-eb12-12ec-a30b-bb1234f1d12a + error: Not Found '429': $ref: '#/components/responses/RateLimited' '503': @@ -3679,6 +3697,14 @@ components: description: | `FAILED` for the failed tests' files only, `ALL` for every test's. Any other value counts as `ALL`. + resultId: + type: integer + minimum: 1 + description: | + Optional. Only the files of the flow run this result belongs to: its + first attempt and every retry, on that one device. Result IDs are the + `id` of each entry in `GET /results/{uploadId}`. Leave it out for the + whole upload. FlowSummaries: type: object required: [statusCode, flows]