is there any way to get the Automated transitioned trigger details from Issue getChangeHistoryManager?


Simillar to the below script runner sample(i,e Date of First Transition), is it possible to get the automated transitioned trigger(i,e user/source i,e kodbuild made commit 202 or Vivek Abraham started review - trigered the transition information) mainly ::

My issue History tab looks as below::

 Automated transition triggered when Vivek Abraham started review KDGPROJECT-128 in 10 - 12/Jul/16 6:27 PM   
StatusIn Progress [ 3 ]CODE REVIEW IN PROGRESS [ 10300 ]


Automated transition triggered when kodbuild made commit 202 in 10 - 13/Jul/16 9:49 PM  
StatusCODE REVIEW COMPLETED [ 10301 ]Done [ 10001 ]


package com.onresolve.jira.groovy.test.scriptfields.scriptsimport com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() changeHistoryManager.getChangeItemsForField(issue, "status").find {     it.toString == "In Progress" }?.getCreated()

Please share your feedback/inputs...


1 answer

1 accepted

2 votes
Answer accepted

Its possible to get those descriptions using the HistoryMetadataManager.

The following example should show you how to get this description for when Stash/Bitbucket transitions the issue to "In Review" when a pull request is created:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.changehistory.ChangeHistory
import com.atlassian.jira.issue.changehistory.metadata.HistoryMetadataManager

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def historyMetadataManager = ComponentAccessor.getComponent(HistoryMetadataManager)
List<ChangeHistory> allChangeHistories = changeHistoryManager.getChangeHistoriesForUser(issue, currentUser)

def relevantChangeHistory = allChangeHistories.find { changeHistory ->
    changeHistory.getChangeItemBeans()*.toString.contains("In Review")
def historyMetadata = historyMetadataManager.getHistoryMetadata(relevantChangeHistory, currentUser)

It will show something like: (Automated transition triggered by pull request #348 in Stash)

It should work the same for other type of automated transitions.

Thanks for your prompt feedback Adam !

It really helping me to identify whether a JIRA issue transition is triggered manually by assignee or automatically from sub-version or crucible app links configured in my workflow.

But When a transition is triggered automatically, it ignores any conditions, validators or permissions configured on the transition - is there any way to handle the conditions/validations before the automatic transition becomes successful based on condition result(PASS or Fail)? 

The transition would be controlled by whatever plugin does the auto-transition, so you would need to ask whoever that is (there may be an option to not skip these).

It sounds like when they perform the transition automatically they skip permissions, validators and conditions. Theres not much we can do from ScriptRunner if this is what they are doing.

This plug in is from Jira, They said at the moment, this is not possible to achieve in JIRA. This is not something we can set in the configuration and we have a feature request raised on this JSW-14579. Thanks again for your response !

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


199 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you