我已经建立了一个包含大型 Java 项目的远程 Mercurial (Hg) 存储库。我想监视对项目的 pom 文件所做的任何更改,并在对 pom 进行更改时接收电子邮件。
我想从通知中排除所有其他文件更改,因为我只对监视任何可能的依赖项更改感兴趣(因此是 POM)。是否有任何使用 Jenkins 的 Mercurial 扩展或解决方法来订阅 Mercurial 存储库中单个文件的更改历史记录?
我已经建立了一个包含大型 Java 项目的远程 Mercurial (Hg) 存储库。我想监视对项目的 pom 文件所做的任何更改,并在对 pom 进行更改时接收电子邮件。
我想从通知中排除所有其他文件更改,因为我只对监视任何可能的依赖项更改感兴趣(因此是 POM)。是否有任何使用 Jenkins 的 Mercurial 扩展或解决方法来订阅 Mercurial 存储库中单个文件的更改历史记录?
通知扩展会发送有关 repo 更改的电子邮件。
Change Context (参见第6 节)为您提供了一种迭代变更集中文件的方法。
将这两件事放在一个自定义挂钩中应该相当简单。查看上下文,仅在提及您的特殊文件时发送电子邮件。
@Ed.ward
我最近不得不这样做(将通知扩展名与更改上下文结合起来)仅在某些文件更改时才通知。为了从您自己的钩子中调用通知钩子,您需要导入 hgext,然后调用 hgext.notify.hook。我的python工作示例:
import re, traceback
import hgext
def check_changegroup(ui, repo, hooktype, node=None, source=None, **kwargs):
ui.note("Checking for files in %s with path: %s\n" % (repo.__class__.__name__, repo.root))
file_match = ".*base.*" #ui.config('monitor_files', 'file_match')
ui.note("file_match: %s\n" % file_match)
file_match_re = re.compile(file_match, re.I)
monitored_file_changed = False
for rev in xrange(repo[node].rev(), len(repo)):
changectx = repo[rev]
for f in changectx.files():
if file_match_re.match(f):
ui.note(" matched: %s\n" % f)
monitored_file_changed = True
if monitored_file_changed:
ui.note("rev: %s from user: %s has changes on monitored files\n" % (rev, changectx.user()))
if monitored_file_changed:
ui.note("calling notify hook\n")
try:
hgext.notify.hook(ui, repo, hooktype, node, source)
except Exception as exc:
ui.warn(('%s error calling notify hook: %s\n') % (exc.__class__.__name__, exc))
traceback.print_exc()
raise