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,176
Community Members
 
Community Events
184
Community Groups

Bitbucket API - Merge Settings

Is it possible via the API to enable/disable and configure the various Merge Checks and Merge Conditions? 

In the documentation I see the ability to manage branch restrictions, but not the above features - https://developer.atlassian.com/cloud/bitbucket/rest/api-group-branch-restrictions/#api-repositories-workspace-repo-slug-branch-restrictions-post

Is there any way to manage the Merge Checks and Conditions in a batch?  I've got a large number of repositories that I need to apply some default settings for and hoping to not have to do it one by one.

Thanks

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 02, 2023

Hello @Chris Lugar ,

Thank you for reaching out to Atlassian Community!

You can indeed use the branch permissions endpoint to change the configuration of merge checks and conditions as well. This can be achieved by using different values for the kind attribute in the body of the request.

Following is an example of API call to add the merge check "No unresolved pull request tasks" to a branch restriction configured to match the glob pattern development/* :

curl -X POST -H "Content-Type: application/json" -u <username>:<app_password> "https://api.bitbucket.org/2.0/repositories/<workspace>/<repoName>/branch-restrictions" -d '{ "branch_match_kind": "glob","kind": "allow_auto_merge_when_builds_pass","pattern": "development/*" }'

You can replace the kind attribute with the string that matches the desired merge check. The following options are available to be used as the value of kind : 

require_tasks_to_be_completed
allow_auto_merge_when_builds_pass
require_passing_builds_to_merge
force
require_all_dependencies_merged
require_commits_behind
restrict_merges
enforce_merge_checks
reset_pullrequest_changes_requested_on_change
require_no_changes_requested
smart_reset_pullrequest_approvals
push
require_approvals_to_merge
require_default_reviewer_approvals_to_merge
reset_pullrequest_approvals_on_change
delete

Please note that only one "kind" value can be used in each request. This means that if want to configure multiple merge checks/conditions, you'll have to make multiple requests with each merge check/condition.

Also, to delete/disable a specific merge/check condition, you will first need to get its ID from the List branch restrictions endpoint , and then provide the ID to Delete a branch restriction rule endpoint.

Hope that helps! Let me know in case you have any questions.

Thank you, @Chris Lugar !

Patrik S

Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 02, 2023

Thanks for sharing @Patrik S  The Bitbucket REST API link that @Chris Lugar posted only mentions 

"kind describes what will be restricted. Allowed values include: push, force, delete and restrict_merges"

Could you please investigate why the REST API document is incomplete and if that is the case update https://api.bitbucket.org/swagger.json and publish the new document.

Thanks, Ulrich

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 02, 2023

Hello @Ulrich Kuhnhardt _IzymesCo_ ,

I'm already in touch with our engineering team and we have created an internal ticket to update the documentation with all the values available for the kind attribute.

Thank you, @Ulrich Kuhnhardt _IzymesCo_ :)

Patrik S

Suggest an answer

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

Atlassian Community Events