[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:
committed by
Denis Patrakeev
parent
4ed05c334a
commit
6635846253
@@ -4,17 +4,17 @@ import groovy.json.JsonOutput
|
|||||||
* Class for work with API gitea
|
* Class for work with API gitea
|
||||||
*/
|
*/
|
||||||
class Gitea implements Serializable {
|
class Gitea implements Serializable {
|
||||||
private Script script
|
private Script script
|
||||||
private String projectURL
|
private String projectURL
|
||||||
private String creds
|
private String creds
|
||||||
|
|
||||||
Gitea(Script script, String projectURL, String creds) {
|
Gitea(Script script, String projectURL, String creds) {
|
||||||
this.projectURL = projectURL
|
this.projectURL = projectURL
|
||||||
this.creds = creds
|
this.creds = creds
|
||||||
this.script = script
|
this.script = script
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: refactor with Gitea token
|
//TODO: refactor with Gitea token
|
||||||
/**
|
/**
|
||||||
* Create new branch from source branch
|
* Create new branch from source branch
|
||||||
* @param srcBranch String - source branch
|
* @param srcBranch String - source branch
|
||||||
@@ -77,4 +77,35 @@ class Gitea implements Serializable {
|
|||||||
|
|
||||||
return result[res.status.toString()]
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user