MergeCheck plugin - obtaining Minimum Approvals config value


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);

  "settings: " + context.getSettings().asMap() );

The ‘Settings’ map is always empty.


You have to hit the REST endpoint that provides this data:


Documentation here:

/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 ?

PUT against this endpoint (and GET to see the current value):


Docs for this specific endpoint are here ("/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}"):

1 Like