Bamboo predefined variable getting overwritten

I have a build with multiple repositories so I'm using a plan variable to define the branch name so that all the repositories get checked out on the same branch for the build.

I defined a plan variable "repobranch". Each repository's branch field is set to ${bamboo.repobranch}. And I set the branch value for this variable on each branch of the plan. This all works great.

But then I wanted to use the branch name in my ant build scripts so I set an environment variable for the build: bamboo_branch=${}.

Now when the build runs, I get the following lines at the start of each task:

command	10-Oct-2013 16:32:27	Substituting variable: ${bamboo.buildNumber} with 110
command	10-Oct-2013 16:32:27	Substituting variable: ${} with ${bamboo.repobranch}
command	10-Oct-2013 16:32:27	Substituting variable: ${} with C:\build\xml-data\build-dir\SFB-BAO-JOB1

So when I echo out ${ENV.bamboo_branch} in ant, the value is "${bamboo.repobranch}". That's the literal value that echos out.

I tried removing the repobranch variable from the whole plan and all branches on the plan, running it, then putting it back, but this problem is still occurring.

Any tips?


1 answer

1 accepted

1 vote
Answer accepted


Bamboo does not interpret variables recursively. In other words if you use variable to define another variable it won't work. That includes built-in variables that derive their value from configuration fields.

My question is why don't you just export


That should work exactly as you expect.

The thing I am trying to control is the checkout of the repositories. I have multiple repositories and I want them all to check out the same branch. Bamboo only checks out the updated branch of the default repository. All other repositories check out "master" by default.

I did define a variable as you suggest so that I can use that in the build itself, but I was trying to control the repository checkout.

I found that the problem was that I was assigning the above variable to the "branch" field of the default repository. I can use that variable in the "branch" field of the other repositories and they will check out the branch assigned to that variable. I am now leaving the default repository set to "master" and then changing it on each branch.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 4 hours ago in United States

Atlassian acquires AgileCraft

         Good Day, Bad bad traffic, not sure why!!!! 1/2 hour commute took me 2 hours today 🤯 What helped me is that I kept browsing LinkedIn until...

25 views 1 0
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you