Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set all repo merge checks to inherited via REST API?

Jonathan Lloyd
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 7, 2018

Now that project level merge checks can be set, does anyone know how make all of the repos inherit them if they were previously set at the repo level?  I had been using the REST API to set them per repo, but now I'd like to just set them at the project level and inherit them.  I've looked through the API browser and I don't see a way to do this.

1 answer

1 vote
Prasanth
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2018

Hey Jonathan

To set that per project you can use the REST end point

/rest/api/1.0/projects/{projectKey}/settings/hooks/{hookKey}/enabled

and HTTP method PUT

To inherit the project's settings to repository, basically you need to use the DELETE method on

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}

To disable the hook per repository, use DELETE method on

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/enabled

To give you an example:

To set the bundled "All reviewers approve" merge check per project, I would use a REST call as below

curl -X PUT -u admin http://<URL>/rest/api/latest/projects/MYF/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:all-approvers-merge-check/enabled

If the hook is already enabled and instead I want to inherit the settings to a repository "integrations-test" under "MYF" project, I would use below one

curl -X DELETE -u admin 'http://<URL>rest/api/latest/projects/MYF/repos/integrations-test/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:all-approvers-merge-check'

You can disable that hook per repository by

curl -X DELETE -u admin 'https://<URL>/rest/api/latest/projects/MYF/repos/integrations-test/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:all-approvers-merge-check/enabled'

and to enable it per repository use PUT

curl -X PUT -u admin 'https://<URL>/rest/api/latest/projects/MYF/repos/integrations-test/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:all-approvers-merge-check/enabled'

To find the hook key for a hook, you can use any developer tools with the browser and check the network call

Check https://docs.atlassian.com/bitbucket-server/rest/5.8.0/bitbucket-rest.html for more details

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events