Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to check if a Variable is set? Edited

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

but 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


Still got the same error.

What is the best way to check if the variable is set or not?


LE: It's related to

4 answers

An indicator of a referenced variable not being set is if your build fails:

You can:

  • reference a global or context specific variable in a build plan or deployment project
  • reference a variable which references another one, deep recursion is allowed

There are couple of limitations:

  • referencing a variable which isn't defined is an error, whole build or deployment will fail if you reference such variable
  • cycles are not allowed and are considered as build or deployment project error.

 If you want to check if a variable is set to the value you'd expect, I'd just create a script task that printed a message with the variable and look for it in the logs while debugging.

echo "Hello ${bamboo.ManualBuildTriggerReason.userName}!"


This doesn't help me, let's say I have some variables in my and they are loaded into bamboo and they are stage specific. 

I would want to check if the variable is defined like a simple bash command: 

if [[ -v blabla ]]; 

this checks that $blabla variable exists.

Is that so complex to do in Bamboo?  

I made a workaround here to check:


PARAMETER_NO_TRAIL_SPACE="$(echo -e "${bamboo.ManualBuildTriggerReason.userName}| sed -e 's/[[:space:]]*$//')"

if [[ -z "$PARAMETER_NO_TRAIL_SPACE" ]]; then    

I am having this same problem.

Only ASCII letters and digits and "_" are supported well on all linux systems and shell scripts as variable names. (regexp:   [a-zA-Z_][a-zA-Z_0-9]* )

See the posix definition of a name for example:

So the workaround is to assign the value to a variable name without dots by using a tool that supports the dots in the variable name like:

bamboo_ManualBuildTriggerReason_userName=$(env | grep ^bamboo\\.ManualBuildTriggerReason\\.userName= | cut -d= -f2-)


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

215 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you