I hope this message finds you well. We are currently facing an issue while trying to protect a branch for all the projects within our group in GitLab. Specifically, we are encountering an error when attempting to add deploy keys to the “Allowed to push and merge” list for the protected branch.
To provide some context and follow the recommended steps from GitLab documentation:
We have navigated to our group using the left sidebar search or direct link.
In the group, we have gone to “Settings” > “Repository.”
We have expanded the “Protected branches” section.
From there, we selected “Add protected branch.”
In the “Branch” text box, we have entered the branch name or a wildcard.
In the “Allowed to merge” list, we have successfully selected a role that can merge into this branch.
However, when attempting to add the deploy keys to the “Allowed to push and merge” list, we are encountering the following error message: “Failed to update branch!”
We would like to reiterate that we are only trying to add the deploy keys to the “Allowed to push and merge” list and not any other role.
Could you please assist us in resolving this issue and guide us on how to successfully add deploy keys to the “Allowed to push and merge” list for the protected branch within our group?
As far as I know, you cannot add a Deploy Key into "Allowed to merge” or “Allowed to push and merge”. Deploy keys are not even listed in the fields and cannot be picked. Deploy key inherits the permissions of the user that created that key. So if the key was created by someone who has permission to merge and push the deploy key should be able to as well.
If you are on self-hosted instance or on Gitlab.com with paid subscription you can create a Access Token instead and use that in the fields.
Hi @balonik ,
Thank you for your reply, the user has owner permissions on that project. I have attached a screenshot where we pick just deploy key and got a message banner. Also we are not self hosting gitlab and are not on a paid version. Since the error message is not clear we could not debug this issue and we just want the deploy keys to have the merge permissions as we do not want any of our maintainers or owners to accidentally push.
I’ve just tried it myself on GitLab.com. Owner permission on a repository, created new Deploy Key with write permissions, created new branch, add the branch to protected and selecting just the Deploy Key in “Allowed to push and merge”. It worked just fine. No issues. Try to unprotect the branch and protect it again with the new settings.