Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Ability to merge based on the comments on a Pull request

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



0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

36 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you