Using octopus variables for different runbooks

I am doing a migration between 2 servers - and it is split into 2 runbooks under the same project.
I have octopus output variables in the first runbook (source) that needs to be used in the second (destination). What is the best way to achieve this?


Hi @omerg

Thanks for your question, and welcome to the Octopus community!

Not knowing exactly the context as to why the runbooks need to be split, I’d say probably the easiest way would be to have the output variables from the first runbook be passed to the second runbook by way of a community library step called Run Octopus Deploy Runbook.

With it’s use in the first runbook, you can trigger the second runbook, and pass variables to the second runbook. The second runbook (destination) will need to have the variables that are needed to be passed to it declared as prompted variables and scoped to only the second runbook, a bit like this:

Then, scope the destination runbook variables:

Then in the first (source) runbook, create the output variables:

Then in the runbook step, pass the output variables in:

When the first runbook runs (source), it will pass the variable values to the second runbook (destination) and print them out using this script:

The first runbook executes a call to the second runbook (via the REST API):

Then the second runbook (destination) prints the values out that were created in the first one:

I hope that helps!


1 Like