RepositoryMergeRequestCheckContext getSettings list

I've found the https://bitbucket.org/atlassian/stash-example-merge-check-config/src/1c11b0e69878?at=master example code when starting to learn about the project. I'm trying to do something similar to what this plugin is doing but I need to check the branch name of the current branch.

The int requiredReviewers = context.getSettings().getInt("reviewers", 0); leads me to believe that the name might be in here somewhere, or perhaps its easily found in the chain of context.getMergeRequest().getPullRequest().

So the first question is, where can I get a list of items available via getSettings and the second is, is there an easier way to get the branch name of the repo for which the merge request check is firing?

1 answer

1 accepted

1 vote
Answer accepted

Hi David,

You are correct, the target branch can be fetched from the PullRequest object. For example:

public void check(@Nonnull RepositoryMergeRequestCheckContext context) {
	Ref toRef = context.getMergeRequest().getPullRequest().getToRef();
}

You then have the option of retrieving the fully qualified string (e.g. refs/heads/master) via getId() or the unqualified string (e.g. master) via getDisplayId().

Regarding your other question, the contents of settings is going to differ from context to context. You can call asMap() on the Settings object to fetch all key/value pairs. 

Thanks.

https://answers.atlassian.com/questions/15290328 was a similar thread to this one which resulted in the same answer.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in United States

Confluence Security Advisory

Good morning Members, Not sure if you are aware. Please read the following: https://www.icloud.com/keynote/0RyJ4VEdNUpjDpGfMhfZx9fEg#Confluence_Security_Advisor More details: https://co...

35 views 1 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you