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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Why is the variable automatically substituted?

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 Community Leader Dec 06, 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

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 Dec 06, 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

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 Dec 09, 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

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 Dec 09, 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

Hi Jimmy,
I understood, thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

694 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you