Is it possible to use plan branches to override the branch on multiple repositories in a plan?
Asked by bbuesker:

<br />

I just started experimenting with Bamboo 4's plan branches feature. It appears that when you enable plan branches and create one (either manually or via auto detection), it only ends up overriding the branch for the default repository. I have multiple repositories in my plan, and they all have the same branching scheme. I would like to have the plan branch be able to override the branch name for all repositories, but this does not appear possible.

Am I missing anything, or is the plan branch feature limited to only overriding the branch for the default repository?


Answers:
author: James Dumay
body: Hi Brian,

Plan branching is limited only to the overriding of the default repositories branch.

There is an [improvement request](https://jira.atlassian.com/browse/BAM-11544) open to make branching apply to all repositories, not just the default - please vote for it :)

Let me know if you have any more feedback regarding Plan Branches :)

Thanks  
James

comments: author: bbuesker
body: Thanks James for the reference to the improvement request. I just voted for it. Unfortunately I don't think I'll be able to use plan branches until that's implemented, but it does look like a potentially useful feature.


author: James Dumay
body: Hmm, you might be able to cheat it a little by making your branch name a Plan level variable, use it in your repositories configuration to specify the branch name, create your plan branches manually then override the branch name variable in the Plan Branch itself.

That way, if the default repositories branch name matches your branch name variable, all plan branches should be able to checkout the same branch for each repo.

Let me know how you go!


author: bbuesker
body: Thanks for that idea James. That does work for me. It's an extra 2 steps (override the branch name variable in the plan branch and define the variable), but that's not that big of a deal. I'll update the JIRA issue with your suggestion as well, in case it is useful for others.


author: David _old account_
body: I tried using a plan variable in the "branch" text field of the Repository definition for non-default repositories, but Bamboo doesn't seem to resolve it. It gives me the following error:

PolySpot Community - Full Master ? PSCOM-FM-111 : Errors getting changes for PSCOM-FM-111  
(java.lang.RuntimeException : com.atlassian.bamboo.repository.InvalidRepositoryException: Cannot determine head revision of 'ssh://9a161dbd-6f8b-4af6-ba39-8d4a883bffea@127.0.0.1:56487/pscom.git' on branch **'${bamboo.repository.branch.name}**'. Branch has probably been removed.)

I'm on Bamboo 4.2, and I'm using Git as you can see.

Did you successfully use a variable in the "branch" field?


author: Per Samuelsson
body: @David,

Not sure if it still applies, since it's a couple of months old, but I did what you tried to do and got it to work. I defined a variable at the plan level, used the name of the variable in the branch fields, and override that variable in one of my plan branches, and got it to fetch/checkout the proper branch (from Git).

I'll leave a reservation since I'm just a week or so into evaluating this product, but I'm rather sure I remember correctly. If you still have problems, I can try again and maybe give some hints or w/e. Let me know.


author: bbuesker
body: |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| I'm currently testing Bamboo 4.3.3 and am running into the same issue @David ran into. It seems that using any plan variable (whether one I configured myself or the ${bamboo.repository.branch.name} one that is auto generated) results in the "Cannot determine head revision" error. My custom variable was working just fine with Bamboo 4.0.1. Did something change that does not allow variable substitution within the branch field for a source repository? |


author: Larry Presswood
body: I seem to be having the same issue with Bamboo 5.1.1.

Any additional ideas and/or a detailed how-too would really be helpful..


author: bbuesker
body: I'm currently testing Bamboo 4.3.3 and am running into the same issue @David ran into. It seems that using any plan variable (whether one I configured myself or the ${bamboo.repository.branch.name} one that is auto generated) results in the "Cannot determine head revision" error. My custom variable was working just fine with Bamboo 4.0.1. Did something change that does not allow variable substitution within the branch field for a source repository?