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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

get a group name if it contains a keyword

Hi Community,


i need to add as watchers a specific group members with a postfunction while creating an issue.

Each user has a client group with all named the same way as its ended with '-clients' .

So i need a method that it fetch the group that name ended with '-clients' and add the members as watchers in the created issue.

The contains i've added below returns only a bloean value and i need to have the name of the group 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level

def currentAppUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name

def groupManager = ComponentAccessor.getGroupManager()
def Keyword = "-administrators"
def searchgroup = groupManager.getGroupNamesForUser(currentAppUser).contains(Keyword)
//log.debug ("Test " + searchgroup)

//return searchgroup

if (searchgroup) {

def watcherManager = ComponentAccessor.getWatcherManager()

def userUtil = ComponentAccessor.userUtil

userUtil.getAllUsersInGroupNames([searchgroup]).each {user ->

watcherManager.startWatching(user, issue)

else {
log.debug ("The user is not a member of a client group" )


Thanks in advance.



1 answer

1 accepted

0 votes
Answer accepted

You are using the wrong method for the filtering as .contains() are designed to return a Boolean value. The following should give you a list of group name (type String). 

def searchgroup = groupManager.getGroupNamesForUser(currentAppUser).findAll{

I hope this helps! 

Hi @Benz Kek _Adaptavist_ ,


Thanks a lot for the reply

yep i used find() method with regex to catch the group having that keyword on it then made a loop to catch all the group containing this keyword.

Like Benz Kek _Adaptavist_ likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

127 views 2 7
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