According to GitHub API user can add label to an issue using this POST request.
I tried using this request but with PR number instead to automatically set label on PR. Here is the function I wrote:
def setLabel (String repository, List labels) {
try {
def response = httpRequest httpMode: 'POST',
url: "https:[Repo_URL]/${repository}/issues/${CHANGE_ID}/labels",
authentication: 'ors_git_service_account',
requestBody: """{
"labels": labels
}"""
} catch (e) {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
echo "\u001B[31magdSlack.setLabels: '" + e.toString() + "'\u001B[0m"
}
throw e
}
}
And the response I get is HTTP/1.1 400 Bad Request
So I get that this request can't be used to labeling PRs.
My question: Is there other method which could be triggered from Jenkinsfile, to add or change PR label?
Closest thing to the question I asked was this question. Commenting API works on issues and PRs but that's not a case for labels.