It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Manjunatha K R Jul 26, 2016

Hi,

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...

-Manju

1 answer

1 accepted

2 votes
Answer accepted
Adam Markham [Adaptavist] Community Leader Jul 27, 2016

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)
historyMetadata.getHistoryMetadata()?.description

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.

Manjunatha K R Jul 28, 2016

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)? 

Adam Markham [Adaptavist] Community Leader Jul 28, 2016

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.

Manjunatha K R Jul 28, 2016

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Join our webinar: “Asset Management: The Role of Context in ITSM” with Atlassian & Riada

  Hi Atlassian Community! This is Teresa from the Jira Service Desk team. On June 19th, I’ll be hosting a webinar “Asset Management: The Role of Context in ITSM” with Atlassian Partne...

137 views 1 3
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you