You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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();
}