
要轉錄請務必標示文章出處: BlogE www.evanlin.com/blog
甚麼是BuildBot?
Buildbot 是一套由Python撰寫的client-server 架構的專案source code追蹤用的伺服器。 主要可以拿來做以下的用途:
需要的軟體:
在這裡先介紹所有你需要的軟體,可以事先去download 下來。
以上的版本已經確定在XP SP2 可以正確安裝並且執行無誤。希望各位也去下載適當版本。必須注意如果把Python換成新的版本(2.5 or 2.6)反而可能會造成安裝失敗。
或者你也可以去以下位置下載懶人包 。
懶人包: http://www.badongo.com/cn/file/12490044
安裝流程:
接下來你還必須要設定master.cfg 才能正常的啟動。
設定Buildbot:
You could connect to http://localhost:10000 to see the server status.
Master.cfg
# 'master.cfg' in your buildmaster's base directory (although the filename
# can be changed with the --basedir option to 'mktap buildbot master').
p4env = {
'port': '192.168.XX.XX:XXXX', #P4 connect port
'user': 'user',
'passwd': 'passwd',
}
# 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 allowable buildslaves. Each element is
# a tuple of bot-name and bot-password. These correspond to values given to
# the buildslave's mktap invocation.
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave("bot1", "123")]
# 'slavePortnum' defines the TCP port to listen on. This must match the value
# configured into the buildslaves (with their --master option)
c['slavePortnum'] = 8010
####### CHANGESOURCES
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes. Any class which implements IChangeSource can be
# put here: there are several in buildbot/changes/*.py to choose from.
from buildbot.changes.p4poller import P4Source
c['change_source'] = P4Source(
p4base='//depot/Shared/Util/P4ReleaseNote/',
p4port = p4env['port'],
p4user = p4env['user'],
p4passwd = p4env['passwd'],
pollinterval= 60,
p4bin = 'c:/p4.exe',
split_file=lambda branchfile: branchfile.split('/',1),)
#from buildbot.changes.pb import PBChangeSource
#c['change_source'] = PBChangeSource()
####### SCHEDULERS
## configure the Schedulers
#Periodic scheduler
from buildbot.scheduler import Scheduler, Periodic
periodic = Periodic("every_1_minutes", ["main"], 60)
c['schedulers'] = [periodic]
####### BUILDERS
from buildbot.process import factory
from buildbot.steps.source import P4 #Must include P4 library.
from buildbot.steps.shell import Configure,Compile,Test
from buildbot.steps.python_twisted import Trial
####### Builder for P4 #############
f1 = factory.BuildFactory()
f1.addStep(P4,
p4port = p4env['port'],
p4user = p4env['user'],
p4passwd = p4env['passwd'],
p4client = 'BuildBot',
p4base = '//depot/Shared/Util/P4ReleaseNote/',
mode = "copy")
b1 = {
'name': "main",
'slavename': "bot1",
'builddir': "main",
'factory': f1
}
c['builders'] = [b1]
####### STATUS TARGETS
c['status'] = []
from buildbot.status import html
c['status'].append(html.WebStatus(http_port=10000))
from buildbot.status import mail
c['status'].append(mail.MailNotifier(fromaddr="evan.lin@evanlin.com",
extraRecipients=["builds@example.com"],
sendToInterestedUsers=False))
####### PROJECT IDENTITY
c['projectName'] = "Buildbot"
c['projectURL'] = "http://buildbot.sourceforge.net/"
c['buildbotURL'] = "http://localhost:10000/"
後記:
總算安裝跟設定好了吧~~~但是這樣僅僅只是讓你下載而已~~關於定期build的部分~ 我會研究出來後再分享給各位。 這裡有一些東西一定要注意到的是。 Perforce client spec must sync with your buildbot path。 如果沒有一樣的話,會發生下載下來檔案在原來client space 的地方,而不會在你預先設定的位置。
Reference link (參考資料)