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=${bamboo.repository.branch.name}.

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: ${bamboo.repository.branch.name} with ${bamboo.repobranch}
command	10-Oct-2013 16:32:27	Substituting variable: ${bamboo.build.working.directory} 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?

Kent

1 answer

1 accepted

This widget could not be displayed.

Hi,

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

bamboo_branch=${bamboo.repobranch}

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 yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

68 views 0 1
Join discussion

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