"Unbound variable" when using set_octopusvariable with set -euo pipefail

We have some bash scripts executing on targets (Linux targets via SSH) that start with set -euo pipefail for safe script execution. This seems to (since at least 2018.10.0 LTS) break the behaviour of set_octopusvariable. Bash throws an error about an unbound variable $3 somewhere inside the implementation of set_octopusvariable.

This was not an issue in the previous version of Octopus Deploy we were using: 2018.4.4.

To reproduce:

  1. Create a new project that can execute bash scripts somewhere.
  2. Add a step in process that executes a script.
  3. Define the script as follows:
set -euo pipefail

echo "Setting MyVariable to Foobar"
set_octopusvariable "MyVariable" "Foobar"
echo "Set MyVariable to Foobar"
  1. Create a new release
  2. Deploy to some environment
  3. The deploy will fail with the error about “Unbound variable $3” in the script step.

Hi Adam,

Once again sorry for the delay to get to this one.
So I had a look at the bash script in https://github.com/OctopusDeploy/Calamari/blob/ec57baa480e950a86d8a0167b54f8e230de37061/source/Calamari.Shared/Integration/Scripting/Bash/Bootstrap.sh#L93 and it seems we forgot to check if that argument is set or not.
I have raised an issue to track this.

I’m hoping to get it fixed today :crossed_fingers:

Regards
John

Thank you for looking into it!

Perhaps the time before closing threads should be increased from the current one month? Or is bumping threads allowed as a way to prevent them from closing?

Hi Adam,

I think bumping the thread is the right way to go.
Also BTW, I have a PR to fix this, shouldn’t take long to get it out now.

Regards
John

1 Like

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