Chinaunix首页 | 论坛 | 博客
  • 博客访问: 85175
  • 博文数量: 9
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2014-12-23 13:15
文章分类
文章存档

2017年(2)

2016年(1)

2015年(4)

2014年(2)

我的朋友

分类: 系统运维

2016-03-31 15:22:16

Buildbot是用python写的跨语言的持续集成编译、测试平台。
下载地址:

1,Buildbot系统架构


Master主进程:管理控制整个系统,如轮询代码库的变动,下发命令道slave
Slave:负责构建系统,在Master的控制下从远端服务器下载代码,编译、构建版本,且可以进行自动化测试。
Master和Slave可以部署在同一台PC上,也可以部署下不同的PC上,保证他们之间网络可通。

2,buildbot编译安装
tar -xvf buildbot-0.8.12.tar.gz
python setup.py

tar -xvf buildbot-slave-0.8.12.tar.gz
python setup.py

查看:
[root@cent190 XXXXX]# buildbot --version
Buildbot version: 0.8.12
Twisted version: 16.0.0

创建master:
buildbot create-master master

打开配置文件:
[root@cent190 XXX]# vi master/master.cfg
# -*- python -*-
from buildbot.plugins import *

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

####### BUILDSLAVES


# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a unique slave name and password.  The same
# slave name and password must be configured on the slave.
c['slaves'] = [buildslave.BuildSlave("CentOS-190", "123456")]     ##添加slave,需与slave中的配置一致


# 'protocols' contains information about protocols which master will use for
# communicating with slaves.
# You must define at least 'port' option that slaves could connect to your master
# with this protocol.
# 'port' must match the value configured into the buildslaves (with their
# --master option)
c['protocols'] = {'pb': {'port': 9989}}     /*master与slave之间通信使用的协议及端口号*/


####### CHANGESOURCES


# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.  Here we point to the buildbot clone of pyflakes.

/*master检测代码源*/
c['change_source'] = []
c['change_source'].append(changes.SVNPoller(
                                                        pollinterval=10*60,
                                                        svnuser="XXX@xxx.net",
                                                        svnpasswd="1qaz!QAZ"))


####### SCHEDULERS


# Configure the Schedulers, which decide how to react to incoming changes.  In this
# case, just kick off a 'runtests' build

##检测到代码发送变化,快速构建系统
c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
                            name="quick",
                            branch=None,
                            treeStableTimer=60,
                            builderNames=["ncs_quick_build"]))

#定期构建系统
c['schedulers'].append(schedulers.Periodic(name="daily",
                builderNames=["ncs_daily_build"],
                periodicBuildTimer=12*60*60))

#c['schedulers'].append(schedulers.ForceScheduler(
#                            name="force",
#
#                            builderNames=["ncs_build"]))


####### BUILDERS


# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which slaves can execute them.  Note that any particular build will
# only take place on one slave.

#构建step
factory = util.BuildFactory()
# check out the source
factory.addStep(steps.SVN(repourl="",
                          username="xxx@xxx.net",
                          password="1qaz!QAZ"))
# run the tests (note that this will require that 'trial' is installed)
factory.addStep(steps.ShellCommand(command=["make","clean"]))
factory.addStep(steps.Compile(command=["make"]))
                              #warningPattern="^(.*)[Ww]arning:(.*)$", #检测warning正则表达式
                              #flunkOnWarnings=True))


c['builders'] = []
c['builders'].append(
    util.BuilderConfig(name="ncs_quick_build",
      slavenames=["CentOS-190"],
      factory=factory))


c['builders'].append(
    util.BuilderConfig(name="ncs_daily_build",
      slavenames=["CentOS-190"],
      factory=factory))
####### STATUS TARGETS


# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.


c['status'] = []


from buildbot.status import html
from buildbot.status.web import authz, auth


authz_cfg=authz.Authz(
    # change any of these to True to enable; see the manual for more
    # options
    auth=auth.BasicAuth([("pyflakes","pyflakes")]),
    gracefulShutdown = False,
    forceBuild = 'auth', # use this to test your slave once it is set up
    forceAllBuilds = 'auth',  # ..or this
    pingBuilder = False,
    stopBuild = False,
    stopAllBuilds = False,
    cancelPendingBuild = False,
)
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))


from buildbot.plugins import status
#c['status'].append(status.WebStatus(8010))

#构建结果邮件抄送相关人员
mn = status.MailNotifier(fromaddr="xxx@xxx.net",
                         sendToInterestedUsers=False,
                         subject="DAMA",
                         mode="all",
                         buildSetSummary="True",
                         extraRecipients=["xxx@xxx.net","yyy@yyy.net"],
                         relayhost="mail.xxx.net",
                         smtpUser="xxx@xxx.net",
                         smtpPassword="1qaz!QAZ")


c['status'].append(mn)


####### PROJECT IDENTITY


# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
# 'titleURL') and is embedded in the title of the waterfall HTML page.


c['title'] = "Pyflakes"
c['titleURL'] = ""


# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.WebStatus page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.


c['buildbotURL'] = ""


####### DB URL


c['db'] = {
    # This specifies what database buildbot uses to store its state.  You can leave
    # this at its default for all but the largest installations.
    'db_url' : "sqlite:///state.sqlite",
}

创建slave:
buildslave create-slave slave localhost:9989 CentOS-190 123456

启动master:
buildbot start master
Following twistd.log until startup finished..
2016-03-31 15:14:18+0800 [-] Log opened.
2016-03-31 15:14:18+0800 [-] twistd 16.0.0 (/usr/bin/python 2.7.5) starting up.
2016-03-31 15:14:18+0800 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2016-03-31 15:14:18+0800 [-] Starting BuildMaster -- buildbot.version: 0.8.12
2016-03-31 15:14:18+0800 [-] Loading configuration from '/home/linshunping/master/master.cfg'
2016-03-31 15:14:19+0800 [-] Setting up database with URL 'sqlite:///state.sqlite'
2016-03-31 15:14:19+0800 [-] setting database journal mode to 'wal'
2016-03-31 15:14:19+0800 [-] adding 1 new changesources, removing 0
2016-03-31 15:14:19+0800 [-] adding 1 new slaves, removing 0
2016-03-31 15:14:19+0800 [-] adding 2 new builders, removing 0
2016-03-31 15:14:19+0800 [-] trying to load status pickle from /home/linshunping/master/ncs_quick_build/builder
2016-03-31 15:14:19+0800 [-] added builder ncs_quick_build with tags None
2016-03-31 15:14:19+0800 [-] trying to load status pickle from /home/linshunping/master/ncs_daily_build/builder
2016-03-31 15:14:19+0800 [-] added builder ncs_daily_build with tags None
2016-03-31 15:14:19+0800 [-] PBServerFactory starting on 9989
2016-03-31 15:14:19+0800 [-] Starting factory
2016-03-31 15:14:19+0800 [-] adding scheduler 'quick'
2016-03-31 15:14:19+0800 [-] adding scheduler 'daily'
2016-03-31 15:14:19+0800 [-] WebStatus using (/home/linshunping/master/public_html)
2016-03-31 15:14:19+0800 [-] Loading builder ncs_daily_build's build 32 from on-disk pickle
2016-03-31 15:14:19+0800 [-] RotateLogSite starting on 8010
2016-03-31 15:14:19+0800 [-] Starting factory
2016-03-31 15:14:19+0800 [-] Setting up http.log rotating 10 files of 10000000 bytes each
2016-03-31 15:14:19+0800 [-] BuildMaster is running
The buildmaster appears to have (re)started correctly.


启动slave:
buildslave start slave
Following twistd.log until startup finished..
2016-03-31 15:14:48+0800 [-] Log opened.
2016-03-31 15:14:48+0800 [-] twistd 16.0.0 (/usr/bin/python 2.7.5) starting up.
2016-03-31 15:14:48+0800 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2016-03-31 15:14:48+0800 [-] Starting BuildSlave -- version: 0.8.12
2016-03-31 15:14:48+0800 [-] recording hostname in twistd.hostname
2016-03-31 15:14:48+0800 [-] Starting factory
2016-03-31 15:14:48+0800 [-] Connecting to localhost:9989
2016-03-31 15:14:48+0800 [Broker,client] message from master: attached
The buildslave appears to have (re)started correctly

浏览器登录界面:



同时相关人员会接收到邮件通知。
阅读(3442) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~