Using plan branches
Plan branches are used to represent a branch in your version control repository, with the plan branch using the same build configuration as your plan.
Tools such as Git and Mercurial encourage a practice called feature branching, where a developer can use a new branch to work in isolation from his or her team members before merging their changes back into main line development.
With plan branches in Bamboo:
- Any new branch created in the repository can be automatically built and tested using the same build configuration as that of the parent plan.
- Any branches deleted from the repository can be deleted automatically from Bamboo according to the settings.
- You have the flexibility to individually configure branch plans, by overriding the parent plan, if required.
- Optionally, changes from the feature branch can be automatically merged back to the "master" (e.g. trunk, default or mainline branch) when the build succeeds.
You can customize how Bamboo manages branches on the system, plan, and branch levels.
Further reading:
Managing plan branches in Bamboo
You can create plan branches manually or automatically. The branch configuration can be provided on the plan level and customized on the branch level. The settings provided in the branch configuration override the settings provided for the plan.
Use the Branch status page for quick access to plan branch information.
You can access the list of all branches in a plan from different places. For example, you can click the Branch icon
next to the plan name in the Build Dashboard view:You can also access the branch list from the Plan summary view:
Subversion branches location
This section is displayed only for plans that use a Subversion source repository. Bamboo assumes that your Subversion repository structure follows the convention for branches, and automatically calculates the branch root URL.
For example, for the fastBuild
repo with this URL: https://svn.mycompany.com/svn/fastBuild/trunk
, Bamboo will expect that branches will be created at this location: https://svn.mycompany.com/svn/fastBuild/branches
.
If your Subversion repository structure follows a different convention, you can specify where repository branches will be created by selecting Change subversion branches URL.
Automatic branch management
Plan branches can be created and deleted automatically based on the updates in the primary source repository. Automatic branch management is available for Git, Mercurial, and Subversion. For other repository types, you can use manual branching. You can override the default settings for a branch, such as values of the variables.
By default, automatic branch management is:
- disabled for branches that you create manually
- enabled for branches that are created automatically
You can specify how often Bamboo checks the primary source repository for new or deleted branches in the general branch settings.
You can override the branch deletion settings in the branch details configuration view.
To hand over the branch management to Bamboo:
- Go to the Plan Configuration view: in the Plan summary view, click the Actions button and select Configure plan
- Click the Branches tab.
Configure the following:
Action Primary source repository branches Description Comments Create plan branch
Manually
Bamboo doesn't create new plan branches automatically. You can create branches manually. When pull request is created Bamboo creates a plan branch automatically when a new pull request is created. If a pull request is merged or declined, Bamboo will disable this plan branch. Note that this option is available for environment that provide support for pull requests. Currently, these are Bitbucket Server, and Bitbucket Cloud. Bamboo creates a plan branch for each new branch detected in the primary source repository. Bamboo creates a plan branch for each new branch detected in the primary source repository that matches the regular expression that you provided. Delete plan branch After branch was deleted from repository When a branch is deleted from the repository, Bamboo will wait for provided number of days before deleting the plan branch.
If you selected Clean up plan branch automatically in the configuration on the branch level, the branch is disabled and deleted according to the daily cleanup rules, regardless of the automatic branch management settings. Clean up plan branch automatically is selected by default for manually created "Plan Branches". After branch inactivity in repository When a branch is inactive for provided number of days, Bamboo will delete the plan branch. If a branch in the primary source repository is inactive, Bamboo does not automatically delete the corresponding plan branch.
- Click Save at the bottom of the view to apply the changes.
Global settings - branch detection interval
Once plan branching is enabled, Bamboo checks for new or deleted branches in the primary source code repository.
You can specify how often Bamboo checks for new branches in the primary source repository in the system settings. The default value is 300 seconds.
To configure the branch detection interval:
- Open the Bamboo Administration view by clicking the cog icon and selecting a section from the list that opens.
- In the Bamboo Administration view, scroll down the menu on the left to find the System section.
- Click General configuration.
- In Global system configurations, set the branch detection interval. Provide the value in seconds, the default value is 300.
Manual branch management
Use manual branching for all supported repository types. You may want to consider using automatic branch management for Git, Mercurial and Subversion repositories.
To manually create a branch of a plan:
- Go to the Plan Configuration view: in the Plan summary view, click the Actions button and select Configure plan
- Click the Branches tab.
- Click Create plan branch in the upper right of the view.
In the Create plan branch view, you can create branches in one of the following ways:
Action Description Select from available VCS branches Select one or more branches from the list of available VCS branches.
At the bottom of the list of the branches you can select the Enable branches check box, which makes all selected branches available for building and change detection.
Create plan branch manually Provide:
- a display name (required) - overrides the VCS branch name
- a branch description - a meaningful description of the branch
- VCS branch name - the name of the branch in the VCS repository
You can select the Enable branches check box, which makes the new branch available for building and change detection.
Click Auto-detect VCS branches to go back to the list of available VCS branches.
- Click Save.
Integrating branches with Jira applications
Check Create Remote Links from Jira Issues to have the plan branch automatically linked, using an issue key in the branch name.
When a developer begins working on a feature described in a Jira application issue, they use Git or Mercurial to branch the repository. If they use the issue key as part of the VCS branch name, Bamboo will detect the issue key and automatically link the new branch to the issue:
- The Jira application issue key needs to be in the name of the branch – 'jb-BDEV-790' and ' BDEV-769 1 ' are valid forms.
- The link shows up right under the breadcrumb on the Build Result Summary for the plan branch, and on the issue too.
To use Jira applications Feature Branching, Bamboo needs an application link to the Jira application server.
Branch repositories
Once the plan branch is created, automatically or manually, all repositories defined in the plan inherit settings from the master plan by default. The only exception is the default repository, which uses one of the following branches:
- branch selected by you during the manual creation of the plan,
- branch detected in VCS in case of automatically created plan.
You can change settings of all repositories defined in the plan branch in the Repositories tab. In this tab, simply put a desired branch name or enable the Change repository settings for this branch plan toggle if you need to modify more settings.
In the Branch summary tab the Repository branches section gives you a quick overview of repositories and branches configured in the plan branch. The Default repository settings changed flag indicates that this repository overrides more settings from the parent plan. The No branch support flag means that a given repository type does not support branches.
Branch notifications
You can get build notifications from branch plans just as you do for master plans.
To specify how notifications are sent by all branches created from a plan, go to the Branches tab for the plan's configuration and choose one of the following options:
- Notify committers and people who have favorited this branch.
- Use the plan's notification settings.
- Notifications should not be sent for this branch.
You can override how notifications are sent from a particular branch plan, if necessary, by going to the Notifications tab on the Plan Branch configuration.
See Configuring notifications for a plan and its jobs for information about plan notifications.
Branch dependencies
You can use build dependencies for plan branches in a similar way to that for plans: a branch plan is triggered only when another branch plan has been successfully built. This can be used to ensure that breaking source code changes associated with one branch plan are detected before they can break the build of a dependent branch plan. Dependencies between master plans are maintained if their branch plans have the same name. See Setting up plan build dependenciesfor further information about dependencies.
Select Trigger Dependencies for Branches, on the Dependencies tab for the plan configuration, if you want plan branches to honor the build dependencies of their respective master plans.
Branch details configuration
Whether a plan branch is created automatically or manually, the master plan maintains the structure and configuration of it's branch plans. However, you can go to the configuration pages to override the following settings in a branch plan:
Branch clean-up
On the Branch Details tab of the branch's configuration, you can specify that a plan branch is not cleaned up automatically.
Please note that 'Automatic Branch Clean-up' is supported for Mercurial, Git (Bamboo 4.1.1 and above) and Subversion (Bamboo 4.2.0 and above).
By default, plan branches are deleted automatically after:
- 7 days after the branch was deleted in the primary source repository OR
- 10 days of branch inactivity in the primary source repository
The values can be specified on the plan level.
Trigger type
On the Branch Details tab of the branch's configuration. See Triggering builds.
Note that you can only configure one trigger for a plan branch, and that this overrides all triggers that may be configured for the master plan.
Merging
On the Branch Details tab of the branch's configuration. Described below.
Source repository
On the Source Repository tab of the plan branch configuration. You can override the default repository settings of a plan on the branch level:
Notifications
On the Notifications tab of the branch's configuration. The options are:
- Notify committers and people who have favorited this branch.
- Use the plan's notification settings.
- Notifications should not be sent for this branch.
See Configuring notifications for a plan and its jobs for information about plan notifications.
Variables
On the Variables tab of the branch's configuration. See Defining plan variables.
Automatic branch merging
Bamboo provides 2 merging models if you choose to automate your branch merging:
- Branch Updater — a branch repo is kept up-to-date with changes to master. Note that changes on your master branch do not trigger branch builds.
- Gatekeeper — the default repo is only updated with changes in the branch that have built successfully.
The automatic branch merge strategy for the master plan can be overridden in an individual plan branch, if required. Automatic branch merging is not available for Subversion.
Branch updater
When to use
The Branch Updater should be used when you want to:
- Automatically merge changes from the team's master branch into your feature branch, after a successful build of the master and branch merge.
- Get notified when the changes on your feature branch are no longer compatible with the team's master branch.
Change detection is available only for the branch you're currently working on.
Configuring
To have recent changes in another repo merged into your branch repo:
- Go to the Branch Details tab of the branch plan's configuration pages.
(Click on the branch icon beside a plan name on the All Plans tab, then choose Actions > Configure Branch.) - Under 'Merging' select Branch Merging Enabled, and then click Branch Updater.
- Use the Merge From list to choose the repo from which changes should be merged with your feature branch.
- Select Push on only if you want those changes merged back into your branch once the build completes successfully,
- Click Save.
Gatekeeper
When to use
The Gatekeeper should be used when you want to:
- Automatically merge your feature branch back into the team's master branch, after a successful build of the merged changes from both branches.
- Get notified when a build of combined changes from both branches fails, preventing the feature branch from being merged back into the team's master branch.
Configuring
To have your successfully built changes pushed to another repo:
- Go to the Branch Details tab of the branch plan's configuration pages.
(Click on the branch icon beside a plan name on the All Plans tab, then choose Actions > Configure Branch.) - Under 'Merging' select Branch Merging Enabled, and then click Gate Keeper.
- Use the Checkout list to choose the repo with which to merge your changes (and to which changes should be pushed).
- Select Push on only if you want your changes pushed to the other repo once the build completes successfully,
- Click Save.
Limitations with plan branches
The following limitations apply to using automated plan branching and merging:
Action | Limitations |
---|---|
Auto plan branching |
|
Manual plan branching |
|
Auto branch merging |
|
Branches wallboard
The branches wallboard displays the status of all the branches and the plan that the branches belong to. The plan's own status always appears first. Plans shown as grey are disabled.
To display the branches wallboard:
- Go to the Plan Summary for the plan that has branches you want to display.
- Choose Actions > Branch Wallboard.