最近需要调整代码的跨平台测试框架,需要在bzr push代码的时候自动触发 测试。
首先将附录的代码放到一个文件中,如push.py,并放在.bazaar/plugins 下
假设代码库位于 172.16.74.152/repo下
本地branch出的目录为/home/user/local-repo
然后在 172.16.74.152/repo 目录下.bzr/branch/branch.conf文件以及本
地/home/user/local-repo目录下.bzr/branch/branch.conf文件中添加
[hooks]
post_push = echo "a";wget -o /dev/null http://localhost:8080/job/greatsql_proxy_2/build
注: “post_push =” 后加需要执行shell 命令
可能还需要配置172.16.74.152机器与本地机的免ssh验证。
附录1
#!/usr/bin/python
from bzrlib import hooks
from bzrlib.branch import Branch
from bzrlib.config import TreeConfig
from bzrlib.errors import BzrError
import subprocess
import os
def branch_base(local, master):
if local is None:
branch = master
else:
branch = local
return branch.base
def run_hook_command(local, master, name, args):
if local is None:
branch = master
else:
branch = local
config = TreeConfig(branch)
command = config.get_option(name, section="hooks")
if command is None:
print "Missing conf for hook"
return
print "Command %s" % command
os.system(command)
def post_push_hook(result):
print "My new revno is %d" % result.new_revno
run_hook_command(result.local_branch, result.master_branch,"post_push",
[branch_base(result.local_branch, result.master_branch),
result.source_branch.base, str(result.old_revno),
result.old_revid, str(result.new_revno), result.new_revid])
转载请注明出自 高孝鑫 的博客
首先将附录的代码放到一个文件中,如push.py,并放在.bazaar/plugins 下
假设代码库位于 172.16.74.152/repo下
本地branch出的目录为/home/user/local-repo
然后在 172.16.74.152/repo 目录下.bzr/branch/branch.conf文件以及本
地/home/user/local-repo目录下.bzr/branch/branch.conf文件中添加
[hooks]
post_push = echo "a";wget -o /dev/null http://localhost:8080/job/greatsql_proxy_2/build
注: “post_push =” 后加需要执行shell 命令
可能还需要配置172.16.74.152机器与本地机的免ssh验证。
附录1
#!/usr/bin/python
from bzrlib import hooks
from bzrlib.branch import Branch
from bzrlib.config import TreeConfig
from bzrlib.errors import BzrError
import subprocess
import os
def branch_base(local, master):
def run_hook_command(local, master, name, args):
def post_push_hook(result):
转载请注明出自 高孝鑫 的博客