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
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.
Caterina Curti
Developer Advocate
Sydney
100 accepted answers
0 comments