So I have 2 variables in my script, one that is set when the user triggers the deployment manually and second when the deployment is triggered automatically. Therefore, one of the variables will not be set.
I've tried:
if [[ -z "${bamboo.ManualBuildTriggerReason.userName}" ]]; then
DEPLOY_USER="${bamboo.DependencyTriggerReason.triggeringBuildResultKey}"
else
DEPLOY_USER="${bamboo.ManualBuildTriggerReason.userName}"
fibut I get a bad substitution error. In the case because the bamboo.ManualBuildTriggerReason.userName doesn't exists when the job deploys automatically.
Then I've tried something like
DEPLOY_USER=${bamboo.DependencyTriggerReason.triggeringBuildResultKey:-${bamboo.ManualBuildTriggerReason.userName}}Still got the same error.
What is the best way to check if the variable is set or not?
LE: It's related to https://community.atlassian.com/t5/Bamboo-questions/Check-if-variable-exists/qaq-p/246606