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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Mention a user in a PR comment using the Bitbucket REST API

Adding a mention to a user in a pull request comment can be a useful way to get their attention faster as well as being more visible when looking at the PR itself.

In Bitbucket, the POST Create a comment on a pull request REST API endpoint is available for adding a comment to a pull request.

If you want to mention to a user while posting the comment, you can add the reviewer Atlassian Account ID in a comment following the @{"+reviewer+"} syntax.

 

Here is an example:

const commentOnPR = async (workspaceUuid, repoUuid, pullRequestId, reviewer) => {
    const bodyData = {
        "content": {
          "raw": "The PR has been automatically assigned to @{"+reviewer+"}"
        }
    };

    try {
        const res = await api
        .asApp()
        .requestBitbucket(route`/2.0/repositories/${workspaceUuid}/${repoUuid}/pullrequests/${pullRequestId}/comments`, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(bodyData)
        });
        const data = await res.json();
        
        // the id of the comment that has been created
        return data.id;
    } catch (error) {
        throw error;
    }
}

 

Want to check a real-life example? New to Forge?

If you would like to try this logic out in a fully working app, I’ve created this one for assigning reviewers automatically when creating a PR. The list of reviewers is in defined in each repository via a configuration file that the apps read.

And if you want to know more, check out the documentation and the getting started example.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events