I have two Jira Servers, in a workflow I have groovy code (Scriptrunner's Custom script post-function) that calls the Jira v2 api to create an issue on the other server.
Running the code as a post-function in a workflow transition, it takes 22 seconds to complete, while running the same code in Scriptrunner's Console takes only 3.
Why is that happening?
def currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser().getUsername()
def jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def originalUser = jiraAuthenticationContext.getLoggedInUser()
def newUser = Users.getByName('...')
def appLinkService = ComponentLocator.getComponent(ApplicationLinkService)
def appLink = appLinkService.getPrimaryApplicationLink(JiraApplicationType)
def Ambiente= appLinkService.getPrimaryApplicationLink(JiraApplicationType).getName()
def post1 = ("/rest/api/2/issue/" )
def input1 = null
input1 = new JsonBuilder([
"fields": [
"project": [
"id": "..."
],
"summary": "...",
"description": "...",
"issuetype": [
"id": "..."
],
"reporter": ["name": currentUser],
"assignee": ["name": currentUser],
"customfield_12723":"..."
]
]).toString()
}
try {
def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory()
def request1 = applicationLinkRequestFactory.createRequest(POST, post1)
.addHeader("Content-Type", "application/json")
.setEntity(input1)
.setSoTimeout(40000)
request1.execute()
}
finally {
}