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

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

Hi,

What specific Workflow information do you want to get?

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

80 views 0 5
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