ScriptRunner to get particular workflow fields (post-transition, statuses, screens at each stage)

Le Markus August 7, 2017

Trying to get this information from each workflow in Jira.  Purpose is to have a report for each one that can be looked over without needing to click into each workflow for information.

Fields needed: Statuses, transitions available at each step, screens and their fields, permissions for transitions.

I looked at the workflow object, but it looks like it doesn't return much more than statuses.  I've been looking through documentation but can't really find where I should go from here.  I looked at the REST api as well, but running a query on it seemed to only return basic information about the workflow, nothing specific enough to be used in a report like this.

I'm doing this in Groovy (ScriptRunner), trying to run in console but open to other ideas.  The 'properties' give some information that looks useful, but not sure what direction to move forward with it.


import com.atlassian.jira.component.ComponentAccessor


//the default workflow
def workflow = ComponentAccessor.getWorkflowManager().getWorkflow("jira")

log.error(workflow.properties)

def screen = ComponentAccessor.getFieldScreenManager()

log.error(screen.properties)
log.error(screen.fieldScreens)

 

Output:

2017-08-07 07:04:31,242 ERROR [runner.ScriptRunnerImpl]: {editable=false, draftWorkflow=false, descriptor=com.opensymphony.workflow.loader.WorkflowDescriptor@49cb2086, updateAuthorName=null, active=false, nextActionId=711, class=class com.atlassian.jira.workflow.DefaultJiraWorkflow, default=true, linkedStatusObjects=[IssueConstantImpl[[GenericEntity:Status][sequence,1][statuscategory,2][name,Open][iconurl,/images/icons/statuses/open.png][description,The issue is open and ready for the assignee to start work on it.][id,1]], IssueConstantImpl[[GenericEntity:Status][sequence,3][statuscategory,4][name,In Progress][iconurl,/images/icons/statuses/inprogress.png][description,This issue is being actively worked on at the moment by the assignee.][id,3]], IssueConstantImpl[[GenericEntity:Status][sequence,5][statuscategory,3][name,Resolved][iconurl,/images/icons/statuses/resolved.png][description,A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.][id,5]], IssueConstantImpl[[GenericEntity:Status][sequence,4][statuscategory,2][name,Reopened][iconurl,/images/icons/statuses/reopened.png][description,This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.][id,4]], IssueConstantImpl[[GenericEntity:Status][sequence,6][statuscategory,3][name,Closed][iconurl,/images/icons/statuses/closed.png][description,The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.][id,6]]], linkedStatuses=[[GenericEntity:Status][sequence,1][statuscategory,2][name,Open][iconurl,/images/icons/statuses/open.png][description,The issue is open and ready for the assignee to start work on it.][id,1], [GenericEntity:Status][sequence,3][statuscategory,4][name,In Progress][iconurl,/images/icons/statuses/inprogress.png][description,This issue is being actively worked on at the moment by the assignee.][id,3], [GenericEntity:Status][sequence,5][statuscategory,3][name,Resolved][iconurl,/images/icons/statuses/resolved.png][description,A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.][id,5], [GenericEntity:Status][sequence,4][statuscategory,2][name,Reopened][iconurl,/images/icons/statuses/reopened.png][description,This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.][id,4], [GenericEntity:Status][sequence,6][statuscategory,3][name,Closed][iconurl,/images/icons/statuses/closed.png][description,The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.][id,6]], displayName=JIRA Workflow (jira), linkedStatusIds=[1, 3, 4, 5, 6], name=jira, systemWorkflow=true, updatedDate=null, mode=live, updateAuthor=null, enabled=true, allActions=[Create Issue, Close Issue (resolveissue), Reopen Issue (commentassign), Start Progress, Resolve Issue (resolveissue), Stop Progress, Close Issue (commentassign)], description=The default JIRA workflow.}

2017-08-07 07:04:31,244 ERROR [runner.ScriptRunnerImpl]: {fieldScreens=[[FieldScreenImpl BDO: Project Management Create Issue Screen], [FieldScreenImpl BDO: Project Management Edit/View Issue Screen], [FieldScreenImpl BDO: Project Management Resolve Issue Screen], [FieldScreenImpl Default Screen], [FieldScreenImpl Resolve Issue Screen], [FieldScreenImpl Workflow Screen]], class=class com.atlassian.jira.issue.fields.screen.DefaultFieldScreenManager}

2017-08-07 07:04:31,244 ERROR [runner.ScriptRunnerImpl]: [[FieldScreenImpl BDO: Project Management Create Issue Screen], [FieldScreenImpl BDO: Project Management Edit/View Issue Screen], [FieldScreenImpl BDO: Project Management Resolve Issue Screen], [FieldScreenImpl Default Screen], [FieldScreenImpl Resolve Issue Screen], [FieldScreenImpl Workflow Screen]]

 

 

1 answer

0 votes
Stephen Cheesley _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.
October 23, 2017

Hi,

What specific Workflow information do you want to get?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events