What does get_octopusvariable returns in case the variable is set to empty?

Hey Guys, I am trying to validate when a variable is empty with if [ -z “$var” ] ; then in bash, but apparently the variable is set to something else. The variable is set to nothing in the project variables, and if I echo it, it outputs “��e”.

Hi Luis,

If the variable doesn’t have a value we return the result of the following command $(decode_servicemessagevalue "null"). So you could update your script as below

blankValue=$(decode_servicemessagevalue "null")

var=$(get_octopusvariable "SomeVariable")
if [ "$var" == "$blankValue" ]; then
    # if the variable is blank

I hope that helps!

Thank you and warm regards,

Awesome, that did the trick, thanks Henrik!

Hey Henrik, that did the trick!


Hi Luis,

Great to hear that you were able to resolve your issue!

Happy deployments!

Thank you,