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

Overriding build-specific variables in Bamboo plans

Ed Dev March 18, 2018

I have 2 repositories in 1 plan where repo1 is the default repo and repo2 is non default. The way Bamboo plans work is the default repo is able to checkout to specific branches, but the non-default can only checkout to master. I am trying find a way around this so that I can pass in a plan variable to repo2 that sets it to what branch I want.This is what I've experimented with so far:

1. Added a plan variable

I override this on a manual build

Screen Shot 2018-03-18 at 11.26.23 AM.png

2. Passed in the plan variable into the script

$bamboo_planRepository_2_branch 

this tells you branch info when you echo it out.

So I tried doing this but didn't work:

Screen Shot 2018-03-18 at 11.40.05 AM.png

What is the correct way to override build-specific variables in Bamboo?

3 answers

1 vote
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2018

What you seem to be after is this feature: https://jira.atlassian.com/browse/BAM-11544 which has been delivered in Bamboo 6.3.0

0 votes
Foong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 9, 2018

Variable is only used for Subversion repository when Bamboo perform Source Code Checkout task. It is not being used in other repository types.

Your requirement for Source Code Checkout task to checkout specific branch for other non default repositories has been implemented in Bamboo 6.3.0:

https://confluence.atlassian.com/bamboo/bamboo-6-3-release-notes-941616828.html#Bamboo6.3ReleaseNotes-Branchingwithmultiplerepositories

0 votes
Jobin Kuruvilla [Adaptavist]
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 Leaders.
March 19, 2018

Not sure what you are trying to do but you can get the branch name from the system variable named:

bamboo.planRepository.<position>.branchName

where position is an optional parameter that specifies the position of the repository in the plan's repository list. If omitted, the first repository in the list is used.

If you are trying to set a variable, why do you want to override a bamboo variable? Why not define a new one?

plan_branch=${bamboo.repo2_branch}

and then use ${plan_branch} in the next steps?

Ed Dev March 19, 2018

Yeah corect this is a system variable:

bamboo.planRepository.<position>.branchName

And that translates in the task script as:

$bamboo_planRepository_2_branch 

And I want to override a different branch to that system variable like my example in the description.

Reason for this is it is a non-default repo, so only master is checked out all the time

Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2018

Those variables are _derived_ from your build configuration, they are not meant to be reset and changing their value won't have any effect other than, well, their value is now changed.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events