Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bamboo predefined variable getting overwritten

Kent Rollins October 10, 2013

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

1 vote
Answer accepted
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 14, 2013

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.

Kent Rollins October 27, 2013

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
TAGS
AUG Leaders

Atlassian Community Events