Using this plugin to comment back to a Bitbucket cloud PR
Vermyndax opened this issue · 1 comments
Vermyndax commented
What feature do you want to see added?
I'd like to find an easy way to post the output from a step in Jenkinsfile back to the pull request comment stream (such as posting the output from a tfsec step, for example).
Is this possible with this plugin, or are there custom-scripted methods that must be employed? Does this plugin offer a way to use the variables and information to post the comment back?
Upstream changes
No response
mguillem commented
AFAIK no built-in functionality for that. We use the httpRequest Plugin for that:
void postPRComment(String bitbucketProject, String repository, String prId, String message) {
String url = "https://##bit-bucket-host##/rest/api/1.0/projects/${bitbucketProject}/repos/${repository}/pull-requests/${prId}/comments"
httpRequest url: url, contentType: 'APPLICATION_JSON', httpMode: 'POST', ignoreSslErrors: true, authentication: 'bitbucket-jenkins-token-rw', requestBody: groovy.json.JsonOutput.toJson([text: message])
}