Example scripts
To homepage
Jira

Get the Name of the Workflow
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.12 - 8.22)

ScriptRunner For Jira (6.56.0)
Language |
groovy
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
getWorkflowNames { MultivaluedMap queryParams ->
def applicationProperties = ComponentAccessor.applicationProperties
final def hostUrl = applicationProperties.getString('jira.baseurl')
final def projectKey = queryParams.getFirst('projectKey')
final def username = '<USERNAME>'
final def password = '<PASSWORD>'
final def headers = ['Authorization': "Basic ${"${username}:${password}".bytes.encodeBase64()}", 'Accept': 'application/json'] as Map
def http = new RESTClient(hostUrl)
http.setHeaders(headers)
def resp = http.get(path: "/rest/projectconfig/1/workflowscheme/${projectKey}") as HttpResponseDecorator
if (resp.status != 200) {
log.warn 'Commander did not respond with 200'
}
def workflowName = resp.data['mappings']['name'] as List
Response.ok(new JsonBuilder(workflowName.first()).toPrettyString()).build()
}
Having an issue with this script?
Report it here