I am using a REST endpoint in scriptrunner and here is the code that I am using. The code is working fine when using an in line script but fails when specifying the file in scriptrunner where the code lies as shown in the following picture:
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegateimport groovy.transform.BaseScriptimport com.atlassian.jira.issue.Issue;import javax.ws.rs.core.MultivaluedMapimport javax.ws.rs.core.Responseimport com.atlassian.jira.component.ComponentAccessorimport org.apache.log4j.Loggerimport com.atlassian.jira.project.Projectimport CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks@BaseScript CustomEndpointDelegate delegatecallSubTaskCreator(httpMethod: "GET", groups: ["jira-users"]) {MultivaluedMap queryParams, String body ->def log1 = Logger.getLogger("atlassian-jira.log")log1.warn("MOUNA CAMELIA223"); Configuration_CreateMultipleSubtasks conf =new Configuration_CreateMultipleSubtasks()def MultipleSubtasksHashMap= conf.getSubTaskCreatorHashMap()String itracCreatemultiplesubtasksProjectCategoriesURL = MultipleSubtasksHashMap["itracCreatemultiplesubtasksProjectCategoriesURL"] as String;// String itracCreatemultiplesubtasksProjectCategoriesURL= "http://itrac-sustservice.eur.ad.sag:5555/web/subtaskmgr/Login.jsp?iTrac=:1:&reporter=:2:"log1.warn("MOUNA CAMELIA223 "+itracCreatemultiplesubtasksProjectCategoriesURL); def user = ComponentAccessor.jiraAuthenticationContext?.loggedInUser def issueId = queryParams.getFirst("issueId") as Long Issue myissue = ComponentAccessor.getIssueManager().getIssueObject(issueId) def issueKey = myissue.getKey() def itracCreatemultiplesubtasksProjectCategoriesURL2 = itracCreatemultiplesubtasksProjectCategoriesURL.replaceAll(":1:", issueKey) def itracCreatemultiplesubtasksProjectCategoriesURL3 = itracCreatemultiplesubtasksProjectCategoriesURL2.replaceAll(":2:", user.getUsername()) log1.warn("The rest endpoint has been executed by the user " +user) Response.temporaryRedirect(URI.create(itracCreatemultiplesubtasksProjectCategoriesURL3)).build() }
Hi @Mouna Hammoudi
Does the user who run the jira service have access to the file ?
Regards
@Florian Bonniec yes the user has all the required accesses. The code works perfectly as an in line script for the same user and fails once specified as a file in the REST endpoint.
It looks like you're new here. Sign in or register to get started.