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

Why is the variable automatically substituted?

DavidJng December 6, 2019

I try to use the variable ${bamboo.repository.name} in further tasks, but it's always substituted with name of the same branch.

Example:
I push on "Branch", the variable has the value "Branch".

I push on "Master", the variable has the value "Branch"... but normally it should have the value "Master", shouldn't it?

Is there another variable to figure out the name of the branch to which something was pushed?

1 answer

1 vote
Elifcan Cakmak
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.
December 6, 2019

Hello,

Yes you need to use branch variable stated in the documentation. What you are using is repository name variable.

https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html

Check out bamboo.planRepository.<position>.branchName variable.

Regards,

Elifcan

DavidJng December 6, 2019

bamboo.planRepository.<position>.branchName uses static values.

f.e. bamboo.planRepository.1.branchName=master and

bamboo.planRepository.2.branch

 

But I need a variable which changes its value depending on the branch it's pushed to.

Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 6, 2019

Hey @DavidJng,

bamboo.planRepository.1.branchName

and

bamboo.planRepository.2.branch

are not different branches with the same repository they are the current branch from two linked repositories in your Build Plan (that is assuming that when your Build Plan executes, you are checking out code from two repositories).

If you use: ${bamboo.planRepository.1.branchName} when pushing to master it will substitute with the value 'master'

If you use ${bamboo.planRepository.1.branchName} when pushing to test_branch it will substitute with the value 'test_branch'

I hope that helps!

-Jimmy

Like Elifcan Cakmak likes this
DavidJng December 9, 2019

Hi @Jimmy Seddon
I always want to checkout everything. But in further tasks I only want to use the branch where something was pushed from. 

f.e.

  1. Push on "test-branch"
  2. Checkout "master" and "test-branch"
  3. use "test-branch" in further tasks 

or

  1. Push on "master"
  2. Checkout "master" and "test-branch"
  3. use "master" in further tasks

 

Best regards,
David

Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 9, 2019

Hi David,

That's not exactly how Source Code checkout tasks work in Bamboo:
https://confluence.atlassian.com/bamboo/checking-out-code-289277060.html

You will only be checking out a single branch per repository at any given time.  But that's precisely how bamboo.planRepository.1.branchName is able to correctly identify the branch you have checked out.

If you are attempting to try and use some other method to checkout multiple branches at the same time, can you describe in a bit more detail what you are using to accomplish this?

-Jimmy

DavidJng December 9, 2019

Hi Jimmy,

Given the following example:

__master
____test-branch1
____test-branch2

If a user pushes something on test-branch1, I want to read a properties file inside test-branch1 and inject them. 

Also I want to do the same for test-branch2 and master without using the Bamboo branch-plan feature.

Best regards,

David

Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 9, 2019

Hi David,

As I stated previously, Bamboo doesn't handle trying to checkout from multiple branches for the same repository at the same time.  From what you have described as far as what you want to accomplish it really sounds like 'test-branch1' & 'test-branch2' should be the master branches of their own repositories, and then you would link all three repositories in your build plan.  That way when someone makes a change in repo 'test-branch1' you will automatically pull the repo for test-branch2 (and it's configuration).

That's just my two cents.

-Jimmy

Like DavidJng likes this
DavidJng December 9, 2019

Hi Jimmy,
I understood, thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events