<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=299788&amp;fmt=gif">

Extracting Workflow and Transition Data with Groovy

Atlassian, Jira

In this blog I will be providing yet another useful Groovy snippet to help you get the data you need from your Jira instance in a jiffy!

For whatever reason, you may find yourself needing to pull data on workflows or transitions. One use case would be that your company is going through a standardization effort and wants to ensure all workflows have a "Pending Review" transition and that everyone uses that exact naming convention.

Below is a script that will iterate over all workflows in your Jira instance and output a list of transition names for each of those workflows. From this script you could do all sorts of variations to extract different data you may need. Maybe you need to match on a specific workflow, or drill deeper into the transitions, or maybe you need to tie transitions back to projects. Whatever your use case, this script will be a good place for you to start.

import com.atlassian.jira.component.ComponentAccessor
def workflowManager = ComponentAccessor.workflowManager
def sb = new StringBuffer()

//iterates over all active workflows in instance
workflowManager.getActiveWorkflows().each {
//output workflow name
//gets workflow transitions
it.getAllActions().each { action ->
//output all transition names for this workflow
sb.append(action.toString() + ", ")
return sb.toString()

Here is some sample output from the above script:

Simple Issue Tracking Workflow:
Create, Start Progress, Stop Progress, Done, Reopen, Reopen and start progress,
NINJA: HR Request Workflow:
Create, In Progress, Done (fieldscreen), Closed (fieldscreen),
ABOOK: Simple Issue Tracking Workflow:
Create, Start Progress, Done, Stop Progress, Done, Reopen, Reopen and start progress, ToMoo, ToInProgress, ToToDo,
Cleco Support v1.1:
Create, Begin Work, To Client Review (fieldscreen), Verified (Resolve Issue Screen), Reopen (Workflow Screen), Close (Resolve Issue Screen)

As you can see, this is a simple yet powerful script that can get you access to data that is typically buried deep within a project configuration. So, next time you find yourself needing to get some data on workflows or transitions within your Jira instance, feel free to hop back over to my blog and save yourself some time by using the starter script I have provided here.

And as always, Happy Automating!

Managing JIRA at Scale White Paper

TAGS: Atlassian, Jira

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Subscribe to Our Newsletter

Recent Blog Posts