Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How add comment to pull request in BitBucket 4.11 via Java API ?

Andrey Budaev January 16, 2019

Unfortunately, from the description of this documentation it is not clear how to add a comment to the pool request itself?

https://docs.atlassian.com/bitbucket-server/javadoc/4.11.1/api/reference/com/atlassian/bitbucket/comment/AbstractAddCommentRequest.AbstractBuilder.html

 

In 5.0, CommentService is used for this purpose, but how to do it in 4.11 without CommentService ?

 

 

1 answer

1 accepted

0 votes
Answer accepted
Andrey Budaev January 17, 2019
@ExportAsService
@Named("PullRequestReviewerListener")
public class PullRequestReviewerListener {

@ComponentImport
private final PullRequestService pullRequestService;

@Inject
public PullRequestReviewerListener(final PullRequestService pullRequestService) {
this.pullRequestService = pullRequestService;
}

public void OnPullRequestOpen(PullRequestOpenedEvent event) {
PullRequest pr = event.getPullRequest();
Repository repository = pr.getToRef().getRepository();

Comment newComment = pullRequestService.addComment(repository.getId(), pr.getId(), "Comment text");
}

}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events