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

Script Runner Merge Check: Code Snippets for approvers is not working

I created a conditional merge check.  Then I copy in either the "Named user approves" or "At least one user from experienced developers group has approved" code snippet and my pull request can still be merged in despite the condition not being met.  I copy in the "Target branch is master" code and that blocks my code merge.  What do I need to change to make these work? 


mergeRequest.pullRequest.reviewers.find {it.approved && == "seniordev"}




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

def userService = ComponentLocator.getComponent(UserService)
mergeRequest.pullRequest.reviewers.findAll { it.approved }.any {
userService.isUserInGroup(it.user, "experienced-developers")


1 answer

1 accepted

0 votes
Answer accepted

The group didn't exist in the scope I was using.  To check that,  you use

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.user.UserService
import com.atlassian.bitbucket.hook.repository.RepositoryHookResult

def userService = ComponentLocator.getComponent(UserService)
if (userService.existsGroup("experienced-developers")) {
   RepositoryHookResult.rejected("Merge rejected", "exists")
} else {
   RepositoryHookResult.rejected("Merge rejected", "does not exist")

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events