recreate_test_run_with_items
Recreate an immutable Jira test run under a new key with added or removed test cases, a new name or folder, and optional result copying or source deletion.
Instructions
Recreate a test run (cycle) under a NEW key with a changed item list, name or folder (GET /testrun/{key} + POST /testrun, plus DELETE /testrun/{key} when deleteOriginal=true). API v1 limitation: a test run is IMMUTABLE — there is no PUT /testrun, so it cannot be renamed, moved or have cases added/removed through the public API; its items are fixed at creation and the run status is derived from item statuses. Escape hatches: recreate_test_run_with_items (public, new key) or the internal-API tools update_test_run / add_test_cases_to_run / remove_test_cases_from_run (same key, require ZEPHYR_ALLOW_INTERNAL_API=true). Items of the new run are: the source items in their original order, minus removeTestCaseKeys, plus addItems appended; of the source items only the planning fields (testCaseKey, environment, assignedTo) are carried over when copyResults is false — all read-only item data is dropped. The new run gets a NEW key and nothing that referenced the old one is updated. Header fields not passed explicitly are inherited from the source run (a JSON null there counts as absent) — EXCEPT testPlanKey, which GET /testrun does not report at all, so the new run starts with no plan association unless you pass it (or re-link with link_test_run_to_plan). A run cannot carry Jira issue links at all: issueLinks is rejected locally, and any value the source run reports is dropped rather than forwarded — link the issues on the test cases instead. removeTestCaseKeys filters the SOURCE items only: a key that also appears in addItems is still added. deleteOriginal runs only after POST /testrun succeeded, so a failed create leaves the source run untouched. copyResults=true carries each kept case's LAST execution over as the initial result of its item, while the item's own environment/assignedTo still win — but GET /testrun reports each item MERGED with its latest execution, so an item whose configured environment/assignedTo were not repeated in that execution has already lost them before this tool reads the run; set them explicitly through addItems when specific values matter. Copied per-step scriptResults are sanitized: this API stores the execution of a case without a STEP_BY_STEP script as an index-less stub, and POST /testrun requires an index on every entry, so entries without a usable index are numbered by position or dropped. removeTestCaseKeys is a SILENT filter (keys that are not items of the run, including nonexistent ones, are ignored), addItems does NOT deduplicate (adding a case that is already an item creates a second item for it, after which test results for that case need matchEnvironment/matchUserKey), and removing every item is allowed and produces a valid run with zero items. The source run survives unless deleteOriginal=true, and is never deleted when creating the new run failed. Returns { key, originalKey, itemCount, copiedResults, deletedOriginal } plus copyResultsNote when result copying hit its page cap. copiedResults counts the KEPT SOURCE items that had a last execution — including the 'Not Executed' execution the server writes for every item at creation, so it is not a count of real executions; addItems entries are never counted, even when they carry a status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of the new run (defaults to the source run's name) | |
| owner | No | Owner (defaults to the source run's value). Jira *user key* (e.g. 'JIRAUSER10000'), NOT a username or e-mail — resolve it with find_jira_user. | |
| folder | No | Full path of an existing TEST_RUN folder starting with "/", e.g. "/Regression" (defaults to the source run's folder). The folder MUST already exist. | |
| version | No | Version name (defaults to the source run's value) | |
| addItems | No | Extra items appended AFTER the kept source items. Each item requires testCaseKey and may carry full execution result fields (status, environment, executedBy, assignedTo, comment, executionTime, actualStartDate, actualEndDate, customFields, issueLinks, scriptResults). | |
| iteration | No | Iteration name (defaults to the source run's value) | |
| issueLinks | No | NOT SUPPORTED for test runs and rejected locally: the API has no such field on its run DTO, so any value (an empty array included) makes POST /testrun answer HTTP 500 and create nothing. Link them with link_issues_to_test_run (internal API) or on the test cases (create_test_case / update_test_case with issueLinks). | |
| testRunKey | Yes | Key of the SOURCE test run to recreate, e.g. PROJ-R123 (PROJ-C123 on older instances) | |
| copyResults | No | Carry the LAST execution of each kept source item over as the initial result of the new run (default false) | |
| testPlanKey | No | Test plan to associate the new run with, e.g. PROJ-P123 (defaults to the source run's value) | |
| customFields | No | Custom field values keyed by field name (defaults to the source run's values) | |
| deleteOriginal | No | Permanently DELETE the source run with all its execution results after the new run was created successfully (default false). The source run is never deleted otherwise, and never when creating the new run failed. | |
| plannedEndDate | No | ISO 8601 (defaults to the source run's value) | |
| plannedStartDate | No | ISO 8601, e.g. 2026-07-20T09:00:00Z (defaults to the source run's value) | |
| removeTestCaseKeys | No | Source items whose test case key is in this list are DROPPED from the new run, e.g. ["PROJ-T5"] |