DO-103_eva_api_class (#10)

Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/10
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
aleksandr.vodyanov
2024-01-10 14:57:45 +03:00
committed by Aleksandr Vodyanov
parent 86740d0fb5
commit 2c65da730e

View File

@@ -23,13 +23,12 @@ class Eva implements Serializable {
/**
* Create new link for Eva Object. For example, tasks
* !WARNING: can to create multiple similar links
* !WARNING: can to create multiple similar links
* @param parentId String - id of Object for which created link
* @param linkName String - name of link
* @param url String - full url of link
* @return Boolean - success or failure create
*/
public createLink(String parentId, String linkName, String url) {
public void createLink(String parentId, String linkName, String url) {
Map body = [
jsonrpc: "1.2",
method: "CmfLink.create",
@@ -41,13 +40,13 @@ class Eva implements Serializable {
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
script.httpRequest(
url: "$host/api/",
contentType: 'APPLICATION_JSON',
httpMode: 'POST',
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
validResponseCodes: '200',
requestBody: JsonOutput.toJson(body)
)
url: "$host/api/",
contentType: 'APPLICATION_JSON',
httpMode: 'POST',
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
validResponseCodes: '200',
requestBody: JsonOutput.toJson(body)
)
}
}
@@ -59,8 +58,12 @@ class Eva implements Serializable {
*/
public String getTaskId(String filterValue, String filterParam = "code") {
String response = getTask(filterValue, filterParam)
Object result = new JsonSlurper().parseText(response).result
return new JsonSlurper().parseText(response).result.id
if (result) {
return result.id
}
return null
}
/**
@@ -83,7 +86,7 @@ class Eva implements Serializable {
contentType: 'APPLICATION_JSON',
httpMode: 'POST',
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
validResponseCodes: '200',
validResponseCodes: '200',
requestBody: JsonOutput.toJson(body)
).content.toString()
}