Send Pull Request Notifications to HipChat Room
January 29, 2017 ยท View on GitHub
-
Provision an API Token for HipChat
- Login to the Hipchat website
- Click the
Edit Profilebutton in the top-right - Click
API Accessin the navigation menu on the left - Enter some descriptive text for the
Label, selectSend Notificationfrom theScopescombo box, and click theCreatebutton - Copy the token from the grid; this is needed to authenticate the request
Note: This value allows API requests to be authenticated as your HipChat user for the selected actions. For that reason, this token should be kept private! It is recommended to create individual tokens for every application that uses the HipChat API, to minimize risk if the token is compromised.
-
Get the
API IDfor the HipChat room that will receive notifications- Login to the Hipchat website
- Click on
Roomsin the navigation bar below the welcome banner - Under the
Activetab, click the name of the room that will receive notifications - Copy the
API IDfrom the grid, this will be included in the notification request
-
Configure Bitbucket to send notifications to a HipChat room
- In Bitbucket, go to the repository that will trigger HipChat notifications
- Click
Settings(a gear icon, if the sidebar is not expanded) - Click
Pull request notificationsunder theADD-ONSheading in the navigation menu on the left. - Scroll down to
Notifications. - Configure triggers as desired
- Configure the URL and Headers sections to communicate with HipChat:
-
URL:
https://api.hipchat.com/v2/room/{roomId}/notificationUse the
API IDof the room in place of{roomId}in the url above. -
Post content:
{ "from": "Bitbucket Pull Request", "color": "green", "message_format": "text", "message": "${PULL_REQUEST_DESCRIPTION}", "card": { "id": "${PULL_REQUEST_FROM_HASH}", "style": "link", "description": { "value": "${PULL_REQUEST_DESCRIPTION}", "format": "text" }, "format": "compact", "notify": false, "url": "${PULL_REQUEST_URL}", "title": "[${PULL_REQUEST_FROM_REPO_NAME}] ${PULL_REQUEST_TITLE} (#${PULL_REQUEST_ID})" } } -
Post content encoding Check the HTML encode checkbox.
-
Headers:
Name Value Content-Typeapplication/jsonAuthorizationBearer {apiToken}Use the
API Tokenin place of{apiToken}in the above value.
-
-
Trigger your notification by performing one of the actions you configured earlier

For further customization of the HipChat notification, refer to the official documentation.