It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

RepositoryMergeRequestCheckContext getSettings list

David Gersh Apr 16, 2015

I've found the 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
Ben Humphreys Atlassian Team May 05, 2015

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. 

David Gersh May 07, 2015

Thanks. was a similar thread to this one which resulted in the same answer.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,095 views 13 15
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you