git - 比特桶服务器 : Send email when pushing a commit that modifies files inside a specific folder

标签 git bitbucket-server

当有人推送一个或多个修改文件夹内文件的提交时,是否有任何方法可以发送电子邮件?

我有一个文件夹,其中包含在大多数提交中不应更改的通用代码的文件。但是,如果有人对这些文件进行更改,我想触发电子邮件/松弛通知。

是否可以使用 BitBucket 服务器?也许有一个插件可以让我这样做?

最佳答案

如果您谈论的是 bitbucket.org,这意味着您无法直接访问/控制 Git 存储库托管服务器,则需要 setup a webhook

该 webhook 将调用您选择的网络监听器,它可以检查 push JSON payload ,并将新提交提取到本地存储库中。

从那里,你可以做一个差异,并检查是否 specific directory content has changed .

是的,如评论所述,Jenkins 服务器(您控制的)可以用作 webhook 监听器,带有 JENKINS/Generic Webhook Trigger Plugin .

OP Gaston K提及 in the comments :

I'm using bitbucket server, which is basically the same but running on my end, I guess.

然后,如果您有权访问服务器,您可以设置一个接收后 Hook :参见“Atlassian / BitBucket / Using repository hooks”。 您将使用 Repository Hook Plugin Module , 定义一个 hook of type "PostRepositoryHook"

然后您可以使用 Atlassian SDK ,编写一个实现该类型的类:

public class NotificationPostRepositoryHook implements PostRepositoryHook<RepositoryHookRequest> {

(例如,参见 Creating a New Plugin from Scratch 开始)

关于git - 比特桶服务器 : Send email when pushing a commit that modifies files inside a specific folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54008049/

相关文章:

git 问题 - 与分支分离

git - 无法在 ubuntu 虚拟机上安装 git

rest - 如何提取 Stash 或 Bitbucket 中所有存储库的列表?

jenkins - 如何让 Jenkins 构建将故障报告回 Bitbucket 服务器?

git - 有没有一种简单的方法可以将代码**并行**推送到 50 个网络服务器?

每次我推送时,Git 都会询问用户名

git - 如何在不推送 git 中的任何其他引用的情况下推送 'refs/replace'?

git - 在 Jenkins 上推广所有构建以掌握

google-chrome - 无法在 Chrome 上登录 Bitbucket

node.js - npm install 模块的权限被拒绝