Bamboo Fails to Push to a Protected Branch of a Bitbucket Repository

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Bamboo may need to push to a remote Bitbucket repository if auto-merging is enabled (Branch Updater or Gatekeeper) for a plan or plan branch, as well as when executing various Git tasks (push branch, push tag, commit changes etc). However, if the VCS branch is a protected one, Bamboo should be given an exception.

Cause

When Bamboo needs to push to a Bitbucket repository and target branch in a protected branch, git operation fails with the error in job build log:

remote: Branch refs/heads/staging can only be modified through pull requests.
remote: Check your branch permissions configuration with the project administrator.


Solution

When adding a Bitbucket Server repository to a plan, Bamboo will generate SSH key pair and add a public key to the repository as an Access Token:

This access key needs to be added as an exception in branch permission rules in the Bitbucket Server repository setting. Start typing http, and you should be able to see the key:

Last modified on Mar 6, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.