From 0c58fbab867d69ebe08a4c2c1284173b3836ab21 Mon Sep 17 00:00:00 2001 From: farthinder Date: Tue, 2 Apr 2024 16:26:06 +0200 Subject: [PATCH] JiraInstanceManagerRest.groovy (#50) * Improving error handling in executeLocalScriptFile() --- pom.xml | 4 ++-- .../jiraInstanceManager/JiraInstanceManagerRest.groovy | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fff0e91..2376277 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eficode.atlassian jirainstancemanager - 2.1.3 + 2.1.4 A groovy library for interacting with Jira REST API. @@ -74,7 +74,7 @@ org.apache.groovy groovy-json - 4.0.8 + ${groovy.version} net.lingala.zip4j diff --git a/src/main/groovy/com/eficode/atlassian/jiraInstanceManager/JiraInstanceManagerRest.groovy b/src/main/groovy/com/eficode/atlassian/jiraInstanceManager/JiraInstanceManagerRest.groovy index b202a7b..4a6d460 100644 --- a/src/main/groovy/com/eficode/atlassian/jiraInstanceManager/JiraInstanceManagerRest.groovy +++ b/src/main/groovy/com/eficode/atlassian/jiraInstanceManager/JiraInstanceManagerRest.groovy @@ -1795,7 +1795,12 @@ final class JiraInstanceManagerRest { HttpResponse scriptResponse = rest.post("/rest/scriptrunner/latest/user/exec/").connectTimeout(4 * 60000).cookie(acquireWebSudoCookies()).contentType("application/json").body(["script": scriptContent]).asJson() - Map scriptResponseJson = scriptResponse.body.getObject().toMap() + Map scriptResponseJson = scriptResponse.body?.getObject()?.toMap() + + if (!scriptResponseJson) { + log.warn("Error getting response after executing ScriptRunner Script, got body:" + scriptResponse.body?.toPrettyString()) + } + ArrayList logRows = scriptResponseJson.snapshot?.log?.split("\n") ArrayList errorRows = scriptResponseJson.errorMessages