Hi, I have a REST endpoint script that returns all transitions in my JIRA instance, along with work some other info such as associated workflow, to and from status etc and produces all the info in CSV format. This works perfectly as it is...
What i would like to do is also return the screen name associated with each transition. Is this possible? Please see my current code below.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
getAllWorkflowTransitions(httpMethod: "GET", groups: ["jira-administrators"]) { MultivaluedMap queryParams, String body ->
def result = []
ComponentAccessor.workflowManager.activeWorkflows.each { wf ->
wf.allActions.each { action ->
wf.getStepsForTransition(action).each {
def destStep = wf.descriptor.getStep(action.unconditionalResult.step)
result.add([
workflow: wf.name,
transitionName: action.name,
transitionId: action.id,
source: it.name,
sourceId: it.id,
sourceGlobalId: it.metaAttributes["jira.status.id"],
destination: destStep.name,
destinationId: destStep.id,
destinationGlobalId: destStep.metaAttributes["jira.status.id"]
])
}
}
}
def output = ""
result.each {
// set CSV header if this is the first record
if (output == "") {
output += it.collect { key, value -> "\"${key}\""}.join(",") + "\n"
}
// output CSV row
output += it.collect { key, value -> "\"${value}\"" }.join(",") + "\n"
}
return Response.ok(output).build();
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.