配置bzr 在push的时候 &…

最近需要调整代码的跨平台测试框架,需要在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])


转载请注明出自 高孝鑫 的博客
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值