# 如何将 Bitbucket Webhook 接入 Pocket Alert？

> 几个简单步骤，连接 Bitbucket Webhook 实现手机推送通知

*18.06.2024*

<!-- source: https://pocketalert.app/zh/blog/how-to-integrate-bitbucket-webhooks-into-pocket-alert -->

[//]: # '# 如何将 Bitbucket Webhook 接入 Pocket Alert'

## 创建新的 Webhook

![创建 webhook](https://cdn.pocketalert.app/guides/git/webhook-create.gif)

1. 前往 [Webhooks](https://pocketalert.app/webhooks) 页面
2. 点击 "Create" 按钮
3. 按以下信息填写表单：
   - **Name**：Webhook 的名称
   - **Application**：要关联该 Webhook 的应用
   - **Device**：要关联该 Webhook 的设备
   - **Message**：Webhook 触发时发送的消息
4. 点击 "Create" 按钮
5. 复制 Webhook 的 URL

**在消息中我们使用 \* 获取全部 JSON，然后确定需要的参数。**

## 将 Webhook 添加到 Bitbucket

![bitbucket 添加 webhook](https://cdn.pocketalert.app/guides/git/bitbucket-add-webhook.gif)

1. 前往仓库设置
2. 点击 "Webhooks" 标签页
3. 点击 "Add webhook" 按钮
4. 按以下信息填写表单：
   - **Title**：Webhook 的标题
   - **URL**：粘贴 Webhook 的 URL
   - **Content type**：application/json
   - **Secret**：Webhook 的密钥
   - **Triggers**：选择希望触发 Webhook 的事件
   - 点击 "Save" 按钮

## 最终设置

在 Bitbucket 中设置好 Webhook 并将提交推送到仓库后，你应该能在 Pocket Alert 应用中看到消息。

你可以定义生成通知所需的变量。

例如，如果你想获取提交信息，可以使用以下代码：

![webhook 更新](https://cdn.pocketalert.app/guides/git/bitbucket-webhook-update.png)

```json
Commit: %push.changes.0.commits.0.message%
Author: %push.changes.0.commits.0.author.user.display_name%

Date: %push.changes.0.commits.0.date%
```

关于变量的更多信息，请参阅 [Webhook 设置](https://info.pocketalert.app/api/webhooks/settings.html)。

## Pocket Alert 应用中的消息示例

![消息](https://cdn.pocketalert.app/guides/git/bitbucket-webhook-messages.png)

---

![消息](https://cdn.pocketalert.app/guides/git/bitbucket-webhook-message.png)

## 总结

在本指南中，我们介绍了如何将 Bitbucket Webhook 接入 Pocket Alert 应用：如何创建新的 Webhook、将 Webhook 添加到 Bitbucket，以及如何在 Pocket Alert 应用中使用消息。我们还展示了 Pocket Alert 应用中的消息示例。希望本指南对你有所帮助。如有任何问题，欢迎随时咨询，我们很乐意提供帮助。感谢阅读本指南。
