i have created this output variable iso_time in step1 , and i want to use this variable in setp 2.
step1:
import datetime
iso_time = datetime.datetime.now().isoformat()
set_octopusvariable(“isotime”, “iso_time”)
When you’re retrieving the variable in step 2, you should be referencing the step 1 name.
e.g. get_octopusvariable(“Octopus.Action[step1].Output.iso_time”)
instead of get_octopusvariable(“Octopus.Action[step2].Output.iso_time”)
File “C:\Octopus\Work\20200815125111-525303-9418\Configure.c3d-435f-8d2f-c4c7af7e5229.py”, line 24, in get_octopusvariable
return octopusvariables[key]
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.
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.
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.