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>