From c42d6896960bb7f839c531bdac0beb532d2d4576 Mon Sep 17 00:00:00 2001 From: Rustam Tagaev Date: Thu, 27 Feb 2025 18:57:42 +0300 Subject: [PATCH] [DO-1648] add new method (!67) Co-authored-by: Rustam Tagaev Co-authored-by: Denis Patrakeev Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/67 Reviewed-by: Vasiliy Chipizhin Reviewed-by: Denis Patrakeev Co-authored-by: Rustam Tagaev Co-committed-by: Rustam Tagaev --- src/tech/avroid/eva/Eva.groovy | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/tech/avroid/eva/Eva.groovy b/src/tech/avroid/eva/Eva.groovy index 6f4ed00..06b2f93 100644 --- a/src/tech/avroid/eva/Eva.groovy +++ b/src/tech/avroid/eva/Eva.groovy @@ -69,11 +69,12 @@ class Eva implements Serializable { } /** - * Getting Eva task information + * Getting Eva task information @Deprecated use getTaskInfo * @param filterValue String - value for search task * @param filterParam String - type of filter for search task. Default value - "code" * @return String - id of task */ + @Deprecated private String getTask(String filterValue, String filterParam = "code") { Map body = [ jsonrpc: "1.2", @@ -93,4 +94,30 @@ class Eva implements Serializable { ).content.toString() } } + + /** + * Getting Eva task information + * @param filterValue String - value for search task + * @param filterParam String - type of filter for search task. Default value - "code" + * @return Map - fields' task + */ + public Map getTaskInfo(String filterValue, String filterParam = "code") { + Map body = [ + jsonrpc: "1.2", + method: "CmfTask.get", + kwargs: [ + filter: [filterParam, "==", filterValue], + ]] + + script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) { + return script.readJSON( text: script.httpRequest( + url: "$host/api/", + contentType: 'APPLICATION_JSON', + httpMode: 'POST', + customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]], + validResponseCodes: '200', + requestBody: JsonOutput.toJson(body) + ).content.toString())['result'] + } + } }