tdacox
July 18, 2019, 4:46pm
1
Hi
How do I determine what the current value of “Minimum Approvals” merge check from the code inside a merge check plugin?
I tried this:
public RepositoryHookResult preUpdate(@Nonnull PreRepositoryHookContext context,
@Nonnull PullRequestMergeHookRequest request) {
int requiredApprovals = context.getSettings().getInt("approvals", 0);
log.info("settings: " + context.getSettings().asMap() );
The ‘Settings’ map is always empty.
Thanks
sylvie
July 19, 2019, 1:08am
2
You have to hit the REST endpoint that provides this data:
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/pull-requests
Documentation here:
https://docs.atlassian.com/bitbucket-server/rest/6.4.1/bitbucket-rest.html#idp307
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/pull-requests => endpoint for a specific repository.
But if I have to change the number of the PROJECT minimum approvals ?
I got the endpoint to enable it (/rest/api/1.0/projects/{projectKey}/settings/hooks), but the API don’t have the option to set the number (count) of approvers.
Anyone knows how to do it ?
sylvie
August 19, 2019, 6:26am
4
PUT against this endpoint (and GET to see the current value):
/rest/api/1.0/projects/{projectKey}/settings/hooks/com.atlassian.bitbucket.server.bitbucket-bundled-hooks:requiredApproversMergeHook/settings
Docs for this specific endpoint are here (“/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}”):
https://docs.atlassian.com/bitbucket-server/rest/6.4.1/bitbucket-rest.html#idp312
1 Like