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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.