bitbucket-branch-source-plugin icon indicating copy to clipboard operation
bitbucket-branch-source-plugin copied to clipboard

Using this plugin to comment back to a Bitbucket cloud PR

Open Vermyndax opened this issue 2 years ago • 1 comments

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

Vermyndax avatar Aug 02 '22 23:08 Vermyndax

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])
}

mguillem avatar Sep 28 '22 15:09 mguillem