水銀小技巧-向服務(wù)器推送時(shí)給群組成員發(fā)送郵件

之前翻譯過一系列文章,探討水銀的使用方法

進(jìn)來由于工作原因,使用了 bitbucket代碼托管網(wǎng)站。這個(gè)網(wǎng)站是為數(shù)不多的支持水銀的代碼托管網(wǎng)站之一。經(jīng)過嘗試,感覺真心不錯(cuò)。里面有這么一個(gè)Service功能,可以添加各種各樣的服務(wù)。其中有一個(gè)服務(wù),叫做Email。這個(gè)服務(wù)可以在有人給這個(gè)倉庫push代碼的時(shí)候,發(fā)送郵件給這個(gè)倉庫的訂閱者。

這的確是一個(gè)比較使用的功能。大家也不可能實(shí)時(shí)關(guān)注倉庫的動(dòng)態(tài),能夠有這種通知來提醒大家是再好不過了。那么,如果不用bitbucket的話,可不可以也有這個(gè)功能呢?通過嘗試,發(fā)現(xiàn)這個(gè)功能可以有。

我在Windows 7和Ubuntu上都嘗試了這個(gè)功能,其實(shí)實(shí)現(xiàn)起來是一模一樣的。我們要做的,只是編輯一個(gè)文件。這個(gè)文件是你倉庫下的.hg下的hgrc文件。當(dāng)然,這也不是我發(fā)明的,網(wǎng)上有教程,只是一開始我摸索了好久都沒成功,后來也是糊里糊涂地就搞定了。

[extensions]
notify=

[hooks]
# Enable either changegroup or incoming or outgoing.
# changegroup will send one email for all incoming changesets,
# whereas incoming sends one email per incoming changeset.
# Note: Configuring both is possible, but probably not
#       what you want, you'll get one email for the group
#       and one for each changeset in the group.
# outgoing will send one email for all outgoing changesets
changegroup.notify = python:hgext.notify.hook
#incoming.notify = python:hgext.notify.hook
#outgoing.notify = python:hgext.notify.hook
[email]
from = ZhongCheng<zhongcheng0519@163.com>
method = smtp

[smtp]
host = smtp.163.com
# Optional options:
username = *******@163.com
password = *******
port = 25
# tls = smtps
tls = none
# local_hostname = me.example.com

# the baseurl is used for constructing hgweb-URLs for the mails
# It can be a dummy value if your repo isn't
# available via http
[web]
baseurl = http://hgserver/hg

[notify]
# Space separated list of change sources. Notifications are sent only
# if it includes the incoming or outgoing changes source. Incoming
# sources can be ``serve`` for changes coming from http or ssh,
# ``pull`` for pulled changes, ``unbundle`` for changes added by
# :hg:`unbundle` or ``push`` for changes being pushed
# locally. Outgoing sources are the same except for ``unbundle`` which
# is replaced by ``bundle``. Default: serve.
sources = serve push unbundle

# set this to False when you're ready for mail to start sending
test = False

# While the subscription information can be included in this file,
#   (in which case, set: config =)
# having it in a separate file allows for it to be version controlled
# and for the option of having subscribers maintain it themselves.
# config = 

[reposubs]
# key is glob pattern, value is comma-separated list of subscriber emails
* = *******@163.com,*******@163.com,**********@qq.com

# You can override the changeset template here, if you want.
# If it doesn't start with \n it may confuse the email parser.
# here's an example that makes the changeset template look more like hg log:
template =
  details:   {baseurl}/{webroot}/rev/{node|short}
  branches:  {branches}
  changeset: {rev}:{node|short}
  user:      {author}
  date:      {date|date}
  description:
  {desc}\n

# max lines of diffs to include (0=none, -1=all)
maxdiff = 300

# if you want to use a shorter repo-name, you can strip off components at the beginning.
# For example to strip off /usr/local/hg/repos from /usr/local/hg/repos/code use
# strip = 5

我這里使用的是163的smtp服務(wù)器,當(dāng)然,技術(shù)好的可以自己搭一個(gè)。另外,qq的smtp服務(wù)器貌似不太好用,Gmail的smtp的端口號(hào)是587。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評(píng)論 19 139
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,023評(píng)論 25 709
  • 告別舊歲,邁入新年,新的一個(gè)四季輪回的時(shí)間重新獲得,而人的生命也將進(jìn)入一段新的旅程。中國俗話里把“年”稱為“年關(guān)”...
    劉西洋閱讀 1,152評(píng)論 0 3

友情鏈接更多精彩內(nèi)容