I am trying to compare the current logged in user during a post function to verify that the transition isn't running via an automation. The automation is set to run as xyz user. So if the user executing the transition matches that username I don't want to assign the current user to the assignee. If the current user doesn't match the username then I want to assign the currently logged in user as the assignee. This is what I have been trying unsuccessfully.
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def issueService = ComponentAccessor.issueService
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
if (user != userManager.getUserByName("xyz"))
{
def validateAssignResult = issueService.validateAssign(user,issue.id, user.username)
if(validateAssignResult.isValid()){ issueService.assign(user,validateAssignResult) }
}
I look at what the step in the post functions return when I run it manually and it appears to have the correct information but the assignee doesn't update. I am new to Jira and Groovy so any help will be appreciated.