配置bzr 在push的时候 &…

来源:互联网 发布:canonmp288清零软件 编辑:程序博客网 时间:2024/05/29 07:23
最近需要调整代码的跨平台测试框架,需要在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/nullhttp://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 isNone:
       branch = master
    else:
       branch = local
    returnbranch.base

def run_hook_command(local, master, name, args):
    if local isNone:
       branch = master
    else:
       branch = local

    config =TreeConfig(branch)
    command =config.get_option(name, section="hooks")
    if commandis None:
       print "Missing conf for hook"
       return
    print"Command %s" % command
   os.system(command)


def post_push_hook(result):
    print "Mynew 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])


转载请注明出自 高孝鑫 的博客
0 0
原创粉丝点击