I have this Listener (below). What I want to happen:
When the issue type is set as 'Enhancement Request' by a specified author, assign the issue to another specified user (user).
If the event author is not the user I've specified, ignore this auto-assignment.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Category;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.INFO)
Issue issue = event.issue as MutableIssue
def issueObject = issue.getKey()
def author = event.getUser().getDisplayName()
if( ["Enhancement Request"].contains(issue.issueType.name) && author == {string username})
{ log.info 'Issue Type is Enhancement Request.'
def userManager = ComponentAccessor.getUserManager()
def user = ComponentAccessor.getUserManager().getUserByKey({string username})
def admin = userManager.getUserByName({string username})
issue.setAssigneeId(user)
return "Author = " + { log.info author.toString() };
return "Assignee = " + { log.info user.toString() };
}
For those of you wondering, I retooled the script and was able to solve it. Here it is:
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
UserManager userManager = ComponentAccessor.getUserManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
def issue = event.getIssue() as MutableIssue
def author = event.getUser().name.toString()
final List<String> projTeam = ['user1', 'user2', 'user3', 'user4']
ApplicationUser assignToUser = userManager.getUserByKey('user5')
if (["Enhancement Request"].contains(issue.issueType.name) && author in projTeam) {
issue.setAssignee(assignToUser)
issueManager.updateIssue(assignToUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
log.info(author + " changed ticket to Enchancement Request.")
}
else
log.info("Non-projTeam user switched issue to Enhancement Request.")
Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!
Help us plant more trees
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.