DO-143_feature_freeze (#8)
+ Added feature freeze for TAVRO Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/8 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
23228632a8
commit
72c8f18cd2
47
src/tech/avroid/api/Gitea.groovy
Normal file
47
src/tech/avroid/api/Gitea.groovy
Normal file
@@ -0,0 +1,47 @@
|
||||
import groovy.json.JsonOutput
|
||||
|
||||
/**
|
||||
* Class for work with API gitea
|
||||
*/
|
||||
class Gitea implements Serializable {
|
||||
|
||||
private Script script
|
||||
private String projectURL
|
||||
private String creds
|
||||
|
||||
Gitea(Script script, String projectURL, String creds) {
|
||||
this.projectURL = projectURL
|
||||
this.creds = creds
|
||||
this.script = script
|
||||
}
|
||||
|
||||
//TODO: refactor with Gitea token
|
||||
/**
|
||||
* Create new branch from source branch
|
||||
* @param srcBranch String - source branch
|
||||
* @param dstBranch String - new branch
|
||||
* @return Boolean - success or failure create
|
||||
*/
|
||||
public Boolean createBranch(String srcBranch, String dstBranch) {
|
||||
Map body = [
|
||||
new_branch_name: dstBranch,
|
||||
old_branch_name: srcBranch
|
||||
]
|
||||
|
||||
Object res = script.httpRequest(
|
||||
url: "${projectURL}/branches",
|
||||
ignoreSslErrors: true,
|
||||
httpMode: 'POST',
|
||||
validResponseCodes: '201,409',
|
||||
authentication: creds,
|
||||
contentType: 'APPLICATION_JSON',
|
||||
requestBody: JsonOutput.toJson(body)
|
||||
)
|
||||
Map result = [
|
||||
'409': false,
|
||||
'201': true
|
||||
]
|
||||
|
||||
return result[res.status.toString()]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user