This console script assigns issues to the users according to the modulus value of the issue's key.
I work as a Project Manager. When I create an issue, I want to automatically assign it to a user based on the modulus value of the issue key. This ensures that all issues have a user assigned when the issue is created. I can adjust the modulus value calculator to balance workloads between users.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def issueManager = ComponentAccessor.issueManager
def projectManager = ComponentAccessor.projectManager
def userManager = ComponentAccessor.userManager
//Specify Project Key
def project = projectManager.getProjectByCurrentKey('<PROJECT_KEY>')
//Specify User's Name
def user1Id = '<USER_NAME>'
def user2Id = '<USER_NAME>'
def user3Id = '<USER_NAME>'
def issues = issueManager.getIssueObjects(issueManager.getIssueIdsForProject(project.id))
issues.sort().each {
def issue = it as MutableIssue
def user1 = userManager.getUserByName(user1Id)
def user2 = userManager.getUserByName(user2Id)
def user3 = userManager.getUserByName(user3Id)
def filter = issue.key.replace("${project.key}-", '') as Integer
if ( filter % 10 == 0 ) {
issue.setAssignee(user1)
} else if ( filter % 2 == 0 || filter % 3 == 0 ) {
issue.setAssignee(user2)
} else {
issue.setAssignee(user3)
}
issueManager.updateIssue(issue.assignee, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}