Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can i obtain the screen name of a specific transition in my REST Endpoint script?

Stephen Marsh March 4, 2019

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();
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events