Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Conditional merge check: How to get content of .yml file and compare it with a specific group


Hi Folks, and especially @Robert Giddings _Adaptavist_ !

I'll split the global task in three smaler.

1. We need to read a content of .yml file that is located in the root. There we need to find a row with "verConfigRefs: - release/13.01.00.x" and after that get only the "13.01.00.x" value.

2. After that we need to check if a current user is a member of any group with pattern "13.01.00.x".

3. If Yes, we allow them to Merge.

I've found a solution or solved particularly for all small tasks and I need your precious help to combine them and get the final result.

With part 1 I found "Load content of JSON file from Pull Request" example. But I need to test it and have it worked. How can I use the similar code inside of Script Console to get Content of file and maybe to try to get the required parameter?

With part 2 I've checked these two scripts and them works. Could you check everything is ok?

This script to compare group name and prefix:

import java.util.regex.Matcher
import java.util.regex.Pattern
def text = "group_prefix"

Matcher m = text =~ /prefix/
if (m) {

 And this one to get list of user groups:

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.user.UserService
import com.atlassian.bitbucket.auth.AuthenticationContext

import com.atlassian.crowd.model.user.Users
import com.atlassian.bitbucket.user.UserSearchRequest
import com.atlassian.bitbucket.util.PageRequest
import com.atlassian.bitbucket.util.PageRequestImpl
import static com.onresolve.scriptrunner.canned.bitbucket.util.BitbucketCannedScriptUtils.unlimitedPager

def dm = ComponentLocator.getComponent(DirectoryManager)
def dir = dm.findAllDirectories().find { == "Bitbucket Internal Directory"}?.id
def us = ComponentLocator.getComponent(UserService)

us.findGroupsByUser("slava", getUnlimitedPager()).values

One question here: Why findGroupsWithUser() function is not working for us? It allows to filter groups of user by specified name. And maybe with this function I could check if a user already a member of a group without matching strings. But it is not a blocker in final solution.

And with part 3 I already set the conditional merge check if user is a member of specific group then allow them to click on the Merge button.


To summarize: Could you help with a final script and to combine all the things above?

Thank you in advance!
With kind regards

1 answer

Hi @Slava Gefen ,

Thank you for your post.

There are quite a few things in there, so I'm going to suggest that you raise a Support Request with us at Adaptavist, in the first instance.

You can do this via our Support Portal for ScriptRunner for Bitbucket here:

Our Support team might be able to help you answer some of your questions. And if not, they will be able to advise you on what to do next.

Hope that helps?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Thanks a lot @Robert Giddings _Adaptavist_ , I raised it.

So, I'll make this question as answered after the support team help me, ok?

Hi @Slava Gefen ,

Sounds good.

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events