I saw the documentation we can surely do it but an example would be useful for better understanding.
API- /rest/branch-permissions/2.0/projects/{projectKey}/repos/{repositorySlug}/restrictions
Correct me if I am wrong with the selection of API call.
I want to give set of users in JSON format and restrict permission for all others except those in that JSON. I am not sure what should be my JSON schema. The same way we do it in the UI using Prevent all changes, except by:
Hi @Ron Bob,
The documentation for branch permissions can be found here and if you find the section that says "Example request representations" you will find an example json request to create a branch permission.
The example givein in the documentation is:
{
"type": "read-only",
"matcher": {
"id": "refs/tags/**",
"displayId": "refs/tags/**",
"type": {
"id": "PATTERN",
"name": "Pattern"
},
"active": true
},
"users": [
"bman",
"tstark",
"hulk"
],
"groups": [
"bitbucket-users"
],
"accessKeys": [
1,
2,
3
]
}
To answer some of your specific questions:
Hope that helps! Let me know if you need more details.
Is there any version dependency for using bitbucket server api 2.0 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bitbucket Server does not have a 2.0 REST API. But the Bitbucket Cloud documentation can be found here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/branch-restrictions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for answering this. May I know how to remove the restrictions. For eg. disable Prevent all changes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you help me with the same problem?
I had try to use POST by curl to restrict branch permission:
curl --insecure -X POST -H "Authorization: Basic <Base64 hash string>" -H "Content-Type: application/json" -d @@request.json https://somedomain.com/rest/branch-permissions/2.0/projects/MYPRJ/repos/myrepo/restriction
@request.json
{
"type": "read-only",
"matcher": {
"id": "timochkin/release-lock",
"displayId": "timochkin/release-lock",
"type": {
"id": "BRANCH",
"name": "Branch"
},
"active": true
},
"users": [
"atimochkin"
],
"accessKeys": [
1,
2,
3
]
}
and
HTTP/1.1 200 Connection established
HTTP/1.1 401
Date: Mon, 16 Dec 2019 06:37:48 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
X-AREQUESTID: @257UFSx97x28529719x0
X-ASEN: SEN-2976722
X-AUSERID: 1246
X-AUSERNAME: atimochkin
Cache-Control: no-cache, no-transform
Vary: X-AUSERNAME,Accept-Encoding
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
WWW-Authenticate: OAuth realm="https%3A%2F%2Fsomedomain.com"
Transfer-Encoding: chunked
{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}
In myrepo, account have Admin permission, what i do wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.