Accessing output variables using python

HI Team,

i have created this output variable iso_time in step1 , and i want to use this variable in setp 2.
import datetime
iso_time =
set_octopusvariable(“isotime”, “iso_time”)

step2 :


i have tried this, but doesn’t seems to be working.

Hi @chandramouli429,

Thanks for getting in touch!

When you’re retrieving the variable in step 2, you should be referencing the step 1 name.
instead of

Hope this helps.


HI @paul.calvert

Thanks for the quick response.

I have updated it. i’m facing the below error


File “C:\Octopus\Work\20200815125111-525303-9418\”, line 24, in get_octopusvariable
return octopusvariables[key]

KeyError: ‘Octopus.Action[Step1].Output.iso_time’


The remote script failed with exit code 1

Hi Chandramouli429,

Paul is right here, but I’ll provide an example so you can see exactly how it works. So lets name Step 1: “DateTimeStep”. This is important for step 2.

So within Step 1, you would have the following:

import datetime
iso_time =
set_octopusvariable("isotime", iso_time)

As you can see, this is very similar to the original step you posted. The only difference is setting the variable within the last argument within set_octopusvariable. This shouldn’t be in quote marks.

Step 2.

print (iso_time)

So within Step 2, the iso_time variable is in quote marks because after variable substitution it will be a string. Variable substitution solves the rest. #{Octopus.Action[DateTimeStep].Output.isotime} gets replaced with the current date time.

You can get more information on these two variable at this link.

Have a great day and let me know if I can help further.



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