Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner Groovy script for Jira group auto assignment

Mathavan September 26, 2024

Hello Expert,

 

Can you please support me for script for auto assignment from jira groups.

I don’t even find the solution anywhere.

 

Thanks,

Mathavan M

2 answers

0 votes
Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2024

Based on what you mentioned above, you would like to assign an issue after issue creation.

That means the best way to go is a post function in the workflow.

In a post function you have access to some variables. Therefore, you can use the "issue" variable to get the current issue. 

The rest can be achieved by the following code. I used the first group and user, but this can be adjusted according to any kind of algorithm. Be sure to put the custom script post function AFTER the "Issue Created" event so that it can be correctly be handled in Jira:

 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.event.type.EventDispatchOption

def groups = ComponentAccessor.groupManager.getAllGroupNames()

def users = ComponentAccessor.groupManager.getUsersInGroup(groups.first())

issue.assignee = users.first()

ComponentAccessor.issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),issue, EventDispatchOption.ISSUE_UPDATED,true)

I hope this will help!
Stefan
Mathavan October 1, 2024

Hello @Stefan Stadler

I am looking for the script Round Robin Auto Assignment.

Use Case:

We have multiple services and Each service has different support team, Each support team has a Jira group.

When ticket is created one of the service, it should assigned to respective team in round robin method.

We tried Jira Automation but, bit slow for assignment.

Can you help with this?

Thanks,
Mathavan

Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2024

Hi Mathavan,

maybe this post can help here.

As I said, the logic can be changed according to the needs, so this might be seen as a starting point for your own modifications:

Updating assignee field using Groovy script Postfu... (atlassian.com)

Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2024

Hi @Mathavan 

there is also some documentation on Round Robin using ScriptRunner:

Round Robin Assign Issue to Users in a Certain Project Role - Adaptavist Library

You may put together both posts and get your solution :)

0 votes
Evgenii
Community Champion
September 26, 2024

Hi, @Mathavan 

Wht do you mean by "auto assignment from jira groups" ? 
Assignement can be done to separate person, not group. What is the logic, you're trying to implement?

Mathavan September 26, 2024

Auto assignment “round robin” method from jira ldap groups.

When issue created we need to assign the ticket to person from ldap groups.

looking forward to hearing from you.

Thanks,

Mathavan

Evgenii
Community Champion
September 26, 2024

@Mathavan for auto-assignement with round-robin from users in group you can use standard jira automation. It allows such functionality.
Using scriptrunner is possible, but not sure how to make "round-robin" with it. You'll need to save, who was assigned previously.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events