How to find all workflows which are using postfunctions of a plugin

We need to upgrade a JIRA, but one of the plugins is not compatible.
How can we find all the workflows which are using the workflow functions from this plugin ?

3 answers

1 accepted

2 votes
Henning Tietgens Community Champion Aug 26, 2013

You could use the Script Runner plugin to search for more detailed uses. I wrote a script to create a list which than can be used e.g. in Excel for further investigations.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import java.util.regex.Matcher

String searchText = 'com.googlecode.jsu.workflow.'

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager()
Collection<JiraWorkflow> workflows = workflowManager.getWorkflows()

String result = "Workflow;Function;Type;Action;Step\r\n"

workflows.each{workflow ->
    workflowXml = workflow.descriptor.asXML()
    Matcher m = workflowXml =~ /${searchText}/
    if (m.find()) {
        String workflow_name = "${}${if(!workflow.isActive()){"(inactive)"} else ''}${if(workflow.isDraftWorkflow()){"(draft)"} else ''}"
        def wf = new XmlParser().parseText(workflowXml)
        List<Node> wf_flat = wf.depthFirst()
            if (it.text() ==~ /.*${searchText}.*/){
                result += "$workflow_name;${getNodeInfo(it,searchText)}\r\n"

String getNodeInfo(Node n, String search) {
    String nodetext = ''
    nodetext += "${n.text() - search}"
    def p = n.parent()
    while (p) {
        switch ( {
            case 'post-functions':
                nodetext += ";post-function"; break
            case 'validators':
                nodetext += ";validator"; break
            case 'conditions':
                nodetext += ";condition"; break
            case 'action':
                nodetext += ";${p.attribute('name')} (${p.attribute('id')})"; break
            case 'step':
                nodetext += ";${p.attribute('name')} (${p.attribute('id')})"; break
            case 'global-actions':
                nodetext += ";GLOBAL"; break
            case 'initial-actions':
                nodetext += ";INITIAL"; break

        p = p.parent()
    return nodetext

You have to adapt the searchText to match the plugin.


That's a cool approach, not requiring to access JIRA 'behind the scenes'
Certainly a candidate for a build-in script (IMO)

Henning - this a beautiful solution. Thanks for sharing!

@Henning Tietgens  – quick question. in the getNodeInfo method – why are you using the minus operator here:

 nodetext += "${n.text() - search}"


It looks like it's removing the search term from nodetext...?  Not sure why you are doing that. Any tips / insight much appreciated!

Henning Tietgens Community Champion Apr 21, 2016

You're right. It's only for shorter list entries.

We are currently using a query on the database, but I'm wondering if there is another approach.
The query is something like

select workflowname
from jira.jiraworkflows
where descriptor like '%iamhuy%'

You could export all workflows as xml-files and then search in these files for that plugin (e.g. com.googlecode.jsu). But I guess searching in in the database is faster.

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
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

686 views 1 18
Join discussion

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