I am trying to get a specific user "build.manager@email.com" to be allowed to push to our Master branch. I have applied branch permissions from the "Branching model" to our repository. I have therefore set "build.manager@email.com" in the exemptions for "Changes without a pull request" but it doesn't work and I get the error:
Branch refs/heads/master can only be modified through pull requests. [09:30:41][Step 4/4] remote: Check your branch permissions configuration with the project administrator.
I have set the git user to be build.manager@email.com on the agent that the repository is being checked out to and before we added the branch permissions in BitBucket the agent was able to push to master with username Build Manager build.manager@email.com.
Does Bitbucket use the email address or the username in the Exemptions dialog box?
James,
Thanks again but now I am confused! Surely BB is comparing the username in the exemptions box with the user name of whatever agent/computer is trying to push to the master branch? Just to be clear - the agent is doing a push from the git bash command line and not through BB, so I thought the username used in the git config on that agent would have to "match" the username defined in BB as being exempt.
Please can you correct my understanding?
You need to focus on the Bitbucket credentials being used to authenticate - either the username in https://username@bitbucket.org/owner/repo, or the account associated with your SSH key. As I've said before, the git committer name and email are not relevant to Bitbucket permissions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's the username.
Git relies on its host operating system to handle authentication and authorization, and the commit metadata (including, but not limited to, the committer email) isn't sent until after authn/authz is complete. With that in mind, it's more efficient to have branch permissions use the Bitbucket username - BB can look up the user's permissions in its database before starting the Git transaction, and it can reject prohibited pushes before they really start.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi James,
Thanks for your answer but it hasn't resolved the issue unfortunately. I get the same error. I am relatively new to git and so to confirm that I am doing it correctly, the git config file has "admin" as user name and the build.manager@email.com address. This is the same as what appears in BB under exemptions.
Whether it makes a difference I am using TeamCity to checkout the repository onto an agent and its from this agent that I am trying to push a change to the master branch.
Could there be settings in TeamCity that are preventing this working?
Thanks again.
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both the git config and the fact that it's TeamCity are irrelevant here. You need to focus on the Bitbucket credentials being used to authenticate, because that (and *only* that) will determine whether Bitbucket gets far enough into the push process for either of those other details to matter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.