[DO-632] add method for create pr comment (#27)

Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/27
Reviewed-by: Yaroslav Bondarenko <yaroslav.bondarenko@avroid.tech>
Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.tech>
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-06-18 10:37:05 +03:00
committed by Denis Patrakeev
parent 4ed05c334a
commit 6635846253

View File

@@ -77,4 +77,35 @@ class Gitea implements Serializable {
return result[res.status.toString()]
}
/**
* create comment in PR
* @param prIndex String - number of PR
* @param message String - comment message in PR
* @return Boolean - True success create
*/
public Boolean createPrComment(String prIndex, String message = '') {
Map body = [
body: message,
]
Object bodyRequest = JsonOutput.toJson(body)
Object res = script.httpRequest(
url: "${projectURL}/issues/${prIndex}/comments",
ignoreSslErrors: true,
httpMode: 'POST',
validResponseCodes: '201',
authentication: creds,
contentType: 'APPLICATION_JSON',
requestBody: bodyRequest
)
if (res.status == 201) {
return true
} else {
return false
}
}
}