Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Branch restrictions - Rest API fails with BRANCH_PERMISSION_VIOLATED

Matija Varjacic March 13, 2024

Hello everyone.

We have a pipeline that creates multiple branches on different repositories.
It uses Rest API to create branches and authentication method is OAuth (oauth consumer is generated in workspace settings). It worked perfectly until we added branch restrictions and now the api call fails with:

{"type": "error", "error": {"message": "You are not allowed to create a branch that
matches the pattern \"release_*\".", "code": "BRANCH_PERMISSION_VIOLATED...

This is how we have branch restrictions setup:

restrictions.png

But it fails because whichever "user" is used when making an API call is not the Administrators group. How can we make it work if there is no user that we can add?
I hope I made it clear. Any help is appreciated.

Thanks.

2 answers

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 14, 2024

Hello @Matija Varjacic and thank you for reaching out to the Community!

Unfortunately, the OAuth consumer "user" is indeed not available to be selected under the branch restrictions page, so if there's a branch restriction protecting the branch you are trying to push to, you'll not be able to push to that branch using OAuth.

We do have a request with our development team to make the OAuth user "selectable" in the branch restrictions, so it would be allowed to make operations in a protected branch. This request is currently being tracked on BCLOUD-20121 . We recommend adding your vote there to express your interest and also watch that ticket to get future updates on its implementation.

As a workaround, while that feature is not available, I'd suggest creating a new bitbucket account to act like a "bot user", and then using that bot's account username and app password to authenticate the request (basic authentication).

Since that "bot" account would be a regular user, you'd be able to invite it to the workspace and select that user in the branch restrictions.

Hope that helps! Should you have any questions, feel free to ask.

Thank you, @Matija Varjacic !

Patrik S

Matija Varjacic March 15, 2024

@

Thank you @Patrik S  for the quick answer and a workaround. I will add my vote and in the meantime I will try the workaround.

 

0 votes
Matija Varjacic March 13, 2024

edit: wrong question

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events