The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Check if variable exists

V
Contributor
May 4, 2014

Is it possible for a bamboo-build to check if a variable exists? I'm having some trouble building a nightly-build-plan which can be run manually, because if it's run manually it passes the ${bamboo.ManualBuildTriggerReason.userName} to my shell-script which executes the nightly build, but if it's run scheduled it exits with an error "bad substitution" because the variable doesn't exist. I'd imagine my problem would be solved if I somehow could check beforehand, if the variable exists and only use it, if it does.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Kristof Boeykens
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 17, 2016

Perhaps a little bit tool late. There is a workaround.

In your bamboo plan, create a variable with the name: ManualBuildTriggerReason.userName

And leave its value empty.

In your script, this variable will be empty in case of a triggered build.

It will not be empty in case of a manual build.

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 4, 2014

What happens if you do an if-else in your shell script?

V
Contributor
May 4, 2014
The job wont run, because it exits as soon as I mention the ${bamboo.ManualBuildTriggerReason.userName}-Variable, since it's nonexistant when the job is run automatically.
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 6, 2014

Mind sharing the script?

V
Contributor
May 7, 2014

I don't think, that the script has anything to do with what I'm asking, but here it is:

#!/bin/bash

user=$1;
pw=$2;
build_plans=(A-A A-B A-C A-D A-E A-F);
for plan in ${build_plans[@]}; do
        `dirname $0`/bamboo.sh --user $user --password $pw --action queueBuild --build "$plan" --wait
done
exit 0

Where bamboo.sh holds the server-info.

gwohletz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 15, 2015

I'm also looking for an answer to this question, i've tried all sorts of ways to test if the bamboo variables exist, but if they do not exist bamboo intercepts things before the script is even run which is very annoying.

TAGS
AUG Leaders

Atlassian Community Events