You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi Everyone!! I am trying to write a merge check, which will allow users to merge only when a specific comment is added to the pull request. I am unable to print any relevant info in the bitbucket logs. Can someone please help in dubbing the below script.
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.comment.CommentService
import com.atlassian.bitbucket.comment.CommentSearchRequest
import com.atlassian.bitbucket.util.PageRequestImpl
import com.atlassian.bitbucket.pull.PullRequestService
import com.atlassian.bitbucket.pull.PullRequestAction
import com.atlassian.bitbucket.pull.PullRequestActivity
import com.atlassian.bitbucket.pull.PullRequestCommentActivity
import com.atlassian.bitbucket.comment.Comment
/* def commentService = ComponentLocator.getComponent(CommentService)
def threads = commentService.searchThreads(
new CommentSearchRequest.Builder(mergeRequest.pullRequest).build(),
new PageRequestImpl(0, PageRequestImpl.MAX_PAGE_LIMIT)
).values */
/*def status = false
for(thread in threads){
def comment = thread.getRootComment().getText()
if (comment.contains('Alpha'))
{ status = true break }
}
return status*/
def pullId = mergeRequest.pullRequest.getId()
def repository = mergeRequest.pullRequest.getToRef().getRepository();
def repoId = repository.getId()
def pullRequestService = ComponentLocator.getComponent(PullRequestService)
def pageReq = new PageRequestImpl(0, 1000);
def activities = pullRequestService.getActivities(repoId, pullId, pageReq);
def status = false
for(activity in activities.getValues().iterator()){
PullRequestActivity pa = (PullRequestActivity) activity;
PullRequestAction prAction = (PullRequestAction)pa.getAction();
if (prAction == PullRequestAction.COMMENTED){
def commentActivity = (PullRequestCommentActivity) pa;
def comment = (Comment)commentActivity.getComment();
def commentMessage = comment.getText();
if (commentMessage.contains('This is a test'))
{ status = true; break; }
}
}
return status
I don't see anywhere in your script where you are telling it to log anything. Is this what you are asking for? How to log? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.