REST Endpoint and other plugins

Claudio Signorini August 28, 2018

I am writing a rest endpoint that uses classes of the Tempo plugin. This is my snippet:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import com.tempoplugin.core.workload.api.WorkloadService
import com.tempoplugin.platform.api.user.UserRepository
import com.tempoplugin.core.workattribute.api.WorkAttributeService

import groovy.json.JsonBuilder
import groovy.transform.BaseScript

import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response

@WithPlugin("is.origo.jira.tempo-plugin")

@BaseScript CustomEndpointDelegate delegate

getUserWorkloadScheme(
httpMethod: "GET", groups: ["jira-administrators"]
) { MultivaluedMap queryParams, String body ->

@PluginModule
WorkAttributeService workAttributeService

return Response.ok(new JsonBuilder(workAttributeService).toString()).build()
}

The workAttributeService is always null.

Is it possible to use third-party plugins in ScriptRunner REST Endpoint?

How can I obtain a valide instance of WorkAttributeService and other Tempo classes?

Thanks!

Claudio

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events