---
title: "Extract JMWE Groovy scripts from Jira workflow XML"
canonical: "https://support.appfire.com/space/SUPPORT/2618720293/Extract%20JMWE%20Groovy%20scripts%20from%20Jira%20workflow%20XML"
format: markdown
---
## Overview

Use this article to extract Groovy scripts used in Jira Misc Workflow Extensions (JMWE) conditions, validators, and post functions from Jira workflow XML files. This process is useful for large Jira instances with many workflows and projects, especially during migrations.

## Background

Jira stores workflow definitions in XML format. JMWE conditions, validators, and post functions that use Groovy scripts are embedded within these XML files. Manual extraction can take time when you have hundreds of workflows.

## Extract Groovy scripts

The following script uses XML Slurper to extract Groovy scripts from a Jira workflow XML file:

```groovy
#!/usr/bin/env groovy
import groovy.xml.XmlSlurper

def xml = new File('Software Simplified Workflow for Project EX.xml').getText('UTF-8')

// Remove DOCTYPE
xml = xml.replaceFirst(/(?s)<!DOCTYPE.*?\]>/, '')
xml = xml.replaceFirst(/(?s)<!DOCTYPE[^>]*>/, '')

def root = new XmlSlurper().parseText(xml)

root.depthFirst().findAll { it.name() == 'action' }.each { action ->
    def transitionName = action.@name.toString()

    action.depthFirst().findAll {
        it.name() == 'arg' && it.@name.toString() == 'groovyExpression'
    }.each { arg ->
        def script = arg.text().trim()
        if (script) {
            println "Transition: ${transitionName}"
            println script
            println "===================================================="
        }
    }
}
```

### Use the script

1. Export the XML file for the Jira workflow from your Jira instance.
2. Replace the file name in the first line of the script with the name of your exported XML file.
3. Run the script using a Groovy interpreter.
4. The script prints each Groovy script found in the workflow, separated by a line of equal signs.

## Example output

The script prints the transition name and Groovy script. For example:

```
Transition: In Progress
return "Hello from Scripted (Groovy) Operation on Validator!"
====================================================
Transition: In Progress
return "Hello from Scripted (Groovy) Operation on Issue Post Function!"
====================================================
```

## Request help

For more help, contact Support or submit a request through the [Appfire Support portal](https://appf.re/support).