Skip to content

fix: preserve --variable values through interactive runbook run - #665

Open
NickJosevski wants to merge 1 commit into
mainfrom
nj/runbook-run-preserve-variables
Open

fix: preserve --variable values through interactive runbook run#665
NickJosevski wants to merge 1 commit into
mainfrom
nj/runbook-run-preserve-variables

Conversation

@NickJosevski

Copy link
Copy Markdown
Contributor

Fixes #582.

In interactive mode, runbook run rebuilt the variable map from the runbook form preview only, so any --variable whose name didn't match a preview control was dropped and the run fell back to the default value. Non-interactive runs already passed every --variable through.

Command-line variables are now carried through unchanged, and names that do match a control are canonicalised to the control's casing so a single spelling reaches the server.

Split out of #609, where it was an unrelated change.

Command-line --variable arguments to `octopus runbook run` were being
silently dropped when the user went through the interactive prompts
(without --no-prompt). Inside askRunbookPreviewVariables, the result
map was rebuilt from the form preview's controls only, so any CLI
variable whose name didn't match a control was discarded. The resulting
runbook run fell back to the prompted variables' default values and the
printed Automation Command was missing the -v args.

This change extracts the variable-resolution logic into a pure helper,
resolveRunbookPreviewVariables, and seeds the result map with the
caller-supplied CLI variables before processing controls. Variables
that do match a control are still canonicalised to the control's name
(preserving the prior case-fixing behaviour). Variables without a
matching control are now passed through unchanged.

Adds unit tests covering: passthrough of unmatched CLI vars,
canonicalisation of mismatched casing, no-prompt when CLI satisfies a
required control, sensitive-variable tracking, and the still-working
prompt path for unprovided required controls.

A similar pattern exists in pkg/cmd/release/deploy/deploy.go around
line 854; not changed here to keep this PR scoped to the reported bug.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompted variable value arguments are stripped from runbook run command

2 participants