I am using a service account to run bash scripts to network servers (no tentacle). I have been trying to pass output variables from one step to another with varying results.
Do linux output variables get deleted when the calamari encounters a different exit code other than 0? Because i am witnessing different results when using the “set-octopusvariable” command in bash. Half of the time, the variable is not transferred to the subsequent step where the “get-octopusvariable” function is used.
Thanks for reaching out, and sorry to hear that you’re having issues here - I just spun up a local reproduction of this, but it always appears to write the output variable so it’s accessible for the next step. Here’s my setup, please let me know how the logic flow compares to what you’re trying to achieve:
Step 1 (Run a script step, blah does not exist, which will throw an error and cause the step to fail):
And just to make sure i understand, each separate step is a new shell in Linux. For instance, if i use a variable for the step name
> stepName="This is my step name 1"
> myString=$(get_octopusvariable "Octopus.Action[$stepName].Output.Var")
> echo "Variable is: $myString"
and i run multiple process steps with this script structure
> stepName="This is my step name 2"
> myString=$(get_octopusvariable "Octopus.Action[$stepName].Output.Var")
> echo "Variable is: $myString"
> stepName="This is my step name 3"
> myString=$(get_octopusvariable "Octopus.Action[$stepName].Output.Var")
> echo "Variable is: $myString"
each step will get the variable set in the each declaration step (1,2,3), regardless of sudo commands?
Step 3 - Name = ReadVariable (set to always run, for the same reason)
echo "This PID is $BASHPID"
stepName="SetVariable"
myString=$(get_octopusvariable "Octopus.Action[$stepName].Output.Var")
echo "Variable for $stepName is: $myString"
stepName="SetVariable2"
myString=$(get_octopusvariable "Octopus.Action[$stepName].Output.Var")
echo "Variable for $stepName is: $myString"