'How to pass branch name dynamically to bamboo plan?

Is there a way to pass/change the branch name to the bamboo plan before 'source checkout' task? I tried using 'script' task and exporting branch related bamboo variables, but that did not work.

Example:

export bamboo_planRepository_branch=my_branch_name
export bamboo_planRepository_1_branch=my_branch_name
export bamboo_repository_git_branch=my_branch_name
export bamboo_repository_branch_name=my_branch_name
echo $bamboo_planRepository_branch
echo $bamboo_planRepository_1_branch
echo $bamboo_repository_git_branch
echo $bamboo_repository_branch_name


Solution 1:[1]

I guess it's not possible to pass branch name dynamically into Source Checkout task.

You might want to use "Automatic branch management" feature (go to Plan Configuration - Branches), this allows to create plan branches for new created branches. So Bamboo will checkout new branch for you automatically.

Solution 2:[2]

you can checkout as many as repo you want but you should never try to repurpose your build plan - each release branch should be tied to its onw plan- you can clone and delete plans as you go

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Borys Kupar
Solution 2 Dinesh Mathiazhagan