Issue with Passing Multi-line Text Variables in Runbook Execution

Hello Octopus Support Team!

I’m currently facing an issue with runbooks in Octopus Deploy where multi-line text variables are not being passed completely between user projects and the main engineering team’s runbook.

Details:

  1. Context: We have a setup where the engineering team maintains a runbook with several required variables. One of these variables is a multi-line text variable. For the public-facing parts of our Octopus Server, we have users who initiate a runbook with a single step: “Run Octopus Runbook”. I have then constructed identical variable sets in these user-specific projects.
  2. Workflow: When a user runs their runbook, they are prompted to enter values for these variables. Once entered, the user-specific project is supposed to pass these variable values to the engineering team’s runbook using the prompted variable values configuration.
  3. Issue: This process works for all variables except for the multi-line text variable. When a multi-line value is provided, only the top line gets passed.For example: If the input is:
SELECT TOP 10 *
FROM Business
WHERE Name LIKE '%ABC'

Only “SELECT TOP 10 *” is received by the engineering runbook.

Expected Behavior: All lines of the multi-line variable should be passed to the engineering runbook without truncation or omission.

Actual Behavior: Only the first line of the multi-line variable is being passed.

Impact: This truncation affects the correct execution of the runbook, potentially leading to inaccurate or incomplete processes.

Request: Kindly assist in rectifying this behavior or suggest a workaround that ensures complete multi-line variable values are passed between projects/runbooks.

Environment Details:

  • Octopus Server Version: v2023.2 (Build 12209)
  • Operating System: Windows 11

Additional Information:

  • Screenshots: [Attach any relevant screenshots that can help in understanding the issue better]
    image

Thank you for your prompt attention to this issue.

Best regards,

Eric

Hi Eric!

Thank you for getting in touch with this great question (and the level of detail provided). I tested with possible ways to handle this for a while, and while there’s likely a better way Octopus could handle multi-line variables, I did finally find out an approach that will retain all the lines in a multi-line variable.

This is to use the Replace filter, replacing the \n newline with the PowerShell syntax (`n). If you set the prompted variable values being passed to the other runbook to look like the following, this should work for any multi-line values (let me know if you’re still experiencing unexpected issues with it, however);

SQL Query::#{SQL Query | Replace “\n” “`n”}

I hope this helps! Let me know how you go, or if you have any further questions or concerns going forward.

Best regards,

Kenny

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.