Create branch trigger bypasses post function custom script using ScriptRunner and validator

Anj Willnecker July 28, 2017

custom ScriptRunner post function on transition Start Progress shows as successful but only updates Assignee field during normal JIRA transition.  When create branch trigger executes the assingee value remains unassigned (not changing) and validator Required fields: Acceptance Criteria is also bypassed.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def Issue issue = issue

if (currentUser != issue.assignee) {
issue.assignee = currentUser
}

2 answers

0 votes
Anj Willnecker August 9, 2017

     

0 votes
Aidan Derossett _Adaptavist_
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.
August 9, 2017

Hey Anj!

So this is just a hunch at this point, but it may be that your script is being executed, but the changed asignee isn't being persisted to the JIRA database. Could you go ahead and try this code? I've made a couple of edits to ensure that the changes are indexed:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue

def issueManager = ComponentAccessor.issueManager
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def Issue issue = issue
if (currentUser != issue.assignee) {
issue.assignee = currentUser
//Persist the assignee change to the DB
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}

 Try that script out and let me know what you find! :)

If it doesn't change anything, we may have to look a little further into the problem.

-Aidan

Anj Willnecker August 9, 2017

Hello, Aidan.  I tried the code and the record remained unassigned when I create branch but auto assigns during normal JIRA worfklow.  Thanks for trying though.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events