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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,619
Community Members
 
Community Events
184
Community Groups

How to allow Workspace/Project Access Token to have write permissions in a (protected) branch

Edited

I believe https://jira.atlassian.com/browse/BCLOUD-20121 is very similar to the issue I am hitting.

I have a workspace access token, and I also am protecting the release branch.

The workspace access token can create tags, but not a release branch. How do I give that permission to the token?

The workaround in that ticket is to use OAuth... and I did not want my jenkins/TeamCity based CI CD pipeline script to have to go through that hassle. Is there another way? How do we create protected branches from non-atlassian CI/CD?

 

To be clear, I am trying to create a branch.


PS build> invoke-restmethod -Method 'POST' -uri "https://api.bitbucket.org/2.0/repositories/$workspace/$slug/refs/branches" -Headers $headers -Body $body
invoke-restmethod : {"type": "error", "error": {"message": "You are not allowed to create a branch that matches the pattern \"release/*\".", "code":
"BRANCH_PERMISSION_VIOLATED", "data": {"key": "BRANCH_PERMISSION_VIOLATED"}}, "data": {"key": "BRANCH_PERMISSION_VIOLATED"}}
At line:1 char:1
+ invoke-restmethod -Method 'POST' -uri "https://api.bitbucket.org/2.0/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
PS build>

PS build> $headers

Name Value
---- -----
Authorization Bearer XXXXXX..
Content-Type application/json
Accept application/json

PS build> $body
{
"name": "release/XXXX",
"target": {
"hash": "HEAD"
}
}
PS build>

2 answers

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 11, 2023

Hello @Sumanta Chakraborty ,

Thank you for reaching out to Atlassian Community!

I've noticed that you have also opened an internal ticket with us, as you have an active Bitbucket subscription, and one of our support engineers is already working with you on that ticket.

I would just like to share here as well, in case others are interested in the same feature, that currently Workspace/Project/Repository Access tokens (WATs, PATs and RATs) are not available to be added in the branch permissions. We have a feature request open to implement this functionality, which can be accessed using the following link : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

The current workaround is using basic auth with an App Password to authenticate the request.

Thank you, @Sumanta Chakraborty !

Patrik S

Looking for guidance...

Basic auth of user kind of works - but I get Rate limited continuously.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events