I have a step template in Python3 with parameter of previous_step_name
prev_step_name = get_octopusvariable(“previous_step_name”)
get_octopusvariable(“Octopus.Action[#{prev_step_name}].Output.ExecutionId”)
get_octopusvariable
Error
return octopusvariables[key]
Error
KeyError: ‘Octopus.Action[#{prev_step_name}].Output.ExecutionId’
Fatal
The remote script failed with exit code 1
I suspect you’re hitting a syntax issue here. Octopus treats everything in quotes as a string, and the standard variable substitution syntax (i.e. #{var}) won’t substitute a variable value that was created in the Python script into the string. The syntax that I got working in my local instance is as follows ({} denotes where to substitute):
Thanks for following up. #{previous_step_name} is a parameter in the step template, and can be substituted in with that standard syntax used by Octopus and will match on name. The prev_step_name is a variable created in the Python script, and substituting the value of it into the string had to use the specific Python syntax.