July 24,2009

buildbot

Ubuntu上安裝Buildbot是很簡單的事情:sudo apt-get install buildbot。

比較麻煩的是設定,大致瀏覽了一下 Manual,還是不知道怎麼設定,轉而找 Google 大神,Mousebender 的這篇Installing buildbot,就很簡單易懂。但由於這篇提供的設定是 2006 年的,現在的設定稍稍有改變,c['bots'] 必須修正為 c['slaves'],後面會提到。

依據 ArchitectureBuildbot必須要有 master 跟 slave,master 負責提供 web 介面跟叫 slave 做事,而 slave 就只聽命令做事,所以設定的時候就要分別設定 master 跟 slave。

master 的設定,得先使用 buildbot create-master [目錄名] 來建立,這會幫你建立一個目錄,並提供你設定檔的範本(master.cfg.sample)。第一步就是要把 master.cfg.sample 改為 master.cfg,然後修改 master.cfg。要調整的基本上有這幾個:
  • c['schedulers'],要排程的時間。
  • f1.addStep(),這決定怎麼編譯。
  • c['slaves']、c['slavePortnum'],slave的名稱、密碼以及要 listen 的 port,待會建立 slave 時會用到。
  • c['projectName'],你專案的名稱。
  • c['projectURL'],你專案的網址。

接著要建立 slave,這邊用 master.cfg.sample 來舉例,也就是假設你剛剛沒改 c['slaves']、c['slavePortnum'] 的內容,所以這邊用 buildbot create-slave [目錄名] localhost:9989 bot1name bot1passwd 來建立 slave,接著把 slave 目錄下的 Makefile.sample 改為 Makefile 即可。

啟動的時候,要先啟動 slave 再啟動 master,啟動的指令都是 buildbot start [目錄名],例如 buildbot start myproject-master、buildbot start myproject-slave。

這樣就大功告成,你可以打開 http://localhost:8010 來看 build 的進度了。

下面是我的設定檔:
# -*- python -*-
c = BuildmasterConfig = {}

####### BUILDSLAVES
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave("myproject-slave", "password", max_builds=1)]
c['slavePortnum'] = 9989

####### CHANGESOURCES
from buildbot.changes.pb import PBChangeSource
c['change_source'] = PBChangeSource()

####### SCHEDULERS
from buildbot.scheduler import Scheduler, Periodic
c['schedulers'] = [
        Periodic("every_12_hours", ["buildbot-full"], 12*60*60 )
]

####### BUILDERS
from buildbot.process import factory
from buildbot.steps.source import CVS
from buildbot.steps.shell import Compile, ShellCommand
from buildbot.steps.python_twisted import Trial
f1 = factory.BuildFactory()
f1.addStep(ShellCommand(command=["/home/user1/build/build.sh"]))
f1.addStep(Compile())

b1 = {'name': "buildbot-full",
      'slavename': 'myproject-slave',
      'builddir': "full",
      'factory': f1,
      }
c['builders'] = [b1]


####### STATUS TARGETS
c['status'] = []

from buildbot.status import html
c['status'].append(html.WebStatus(http_port=8010))

####### PROJECT IDENTITY
c['projectName'] = "myproject"
c['projectURL'] = "http://myproject-server"
c['buildbotURL'] = "http://localhost:8010/"


Posted by elleryq at 樂多Roodo! │15:58 │回應(5)引用(0)資訊相關Idea與筆記
樂多分類:網路/3C 共同主題:linux 工具:編輯本文
標籤:c,c++,note,python
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/9519357
回應文章

你好,有幾個問題要請教一下:
我是安裝buildbot-0.7.9.zip on windows XP SP2.
1. 我可以建立 master and slave,但當我執行 c:\>buildbot start slave 時,該程序有執行,但卻不會結束! master 也有同樣現象。正常嗎? 該程序執行需多久時間?
2. c['projectURL'] 指的是 svn 建立的 repository 嗎?
3. 以下是我的 master.cfg. source code 放在 http://localhost/svn/evalbd/
Posted by Allen at July 28,2009 16:28

===== master.cfg =========
c = BuildmasterConfig = {}

####### BUILDSLAVES
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave("bot1name", "bot1passwd")]

c['slavePortnum'] = 9989

####### CHANGESOURCES

from buildbot.changes.pb import PBChangeSource
c['change_source'] = PBChangeSource()

####### SCHEDULERS

## configure the Schedulers

from buildbot.scheduler import Scheduler
c['schedulers'] = []
c['schedulers'].append(Scheduler(name="all", branch=None,
treeStableTimer=2*60,
builderNames=["buildbot-full"]))


####### BUILDERS

from buildbot.process import factory
from buildbot.steps.source import SVN
from buildbot.steps.shell import Compile
from buildbot.steps.python_twisted import Trial
f1 = factory.BuildFactory()
f1.addStep(Compile())
f1.addStep(Trial(testpath="."))

b1 = {'name': "buildbot-full",
'slavename': "bot1name",
'builddir': "full",
'factory': f1,
}
c['builders'] = [b1]


####### STATUS TARGETS

c['status'] = []

from buildbot.status import html
c['status'].append(html.WebStatus(http_port=8010))

####### PROJECT IDENTITY

c['projectName'] = "evalbd"
c['projectURL'] = "http://svn/evalbd"

c['buildbotURL'] = "http://localhost:8010/"
Posted by Allen at July 28,2009 16:30
1. 我是用 linux,執行過一會,就結束了,此時程序已經執行起來。Windows 的話,我不清楚。
2. c['projectURL'] 指的是你專案的網址,隨便你填,這只是在網頁頁面上顯示你專案名稱的地方會有個超連結,超連結就是連到你指定的地方。
3. 你可以用 buildbot checkconfig 來檢查設定檔是否有誤。
Posted by elleryq at July 29,2009 00:07

我在 CentOS 下會出現以下訊息:
可否請教哪裡出問題? 用 checkconfig 說沒問題!
我用SVN!

#buildbot start ProjectMaster
2009-07-30 18:48:32+0800 [-] Log opened.
2009-07-30 18:48:32+0800 [-] twistd 8.2.0 (/usr/bin/python 2.4.3) starting up.
2009-07-30 18:48:32+0800 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2009-07-30 18:48:32+0800 [-] Starting factory
2009-07-30 18:48:32+0800 [Uninitialized] will retry in 3 seconds
2009-07-30 18:48:32+0800 [Uninitialized] Stopping factory
2009-07-30 18:48:35+0800 [-] Starting factory
2009-07-30 18:48:35+0800 [Uninitialized] will retry in 8 seconds
2009-07-30 18:48:35+0800 [Uninitialized] Stopping factory
2009-07-30 18:48:44+0800 [-] Starting factory
2009-07-30 18:48:44+0800 [Uninitialized] will retry in 22 seconds
2009-07-30 18:48:44+0800 [Uninitialized] Stopping factory
2009-07-30 18:49:06+0800 [-] Starting factory
2009-07-30 18:49:06+0800 [Uninitialized] will retry in 47 seconds
2009-07-30 18:49:06+0800 [Uninitialized] Stopping factory
2009-07-30 18:49:54+0800 [-] Starting factory
2009-07-30 18:49:54+0800 [Uninitialized] will retry in 114 seconds
2009-07-30 18:49:54+0800 [Uninitialized] Stopping factory
2009-07-30 18:51:49+0800 [-] Starting factory
2009-07-30 18:51:49+0800 [Uninitialized] will retry in 361 seconds
2009-07-30 18:51:49+0800 [Uninitialized] Stopping factory
2009-07-30 18:57:50+0800 [-] Starting factory
2009-07-30 18:57:50+0800 [Uninitialized] will retry in 342 seconds
2009-07-30 18:57:50+0800 [Uninitialized] Stopping factory
2009-07-30 19:01:33+0800 [-] Received SIGTERM, shutting down.
2009-07-30 19:01:33+0800 [-] Main loop terminated.
2009-07-30 19:01:33+0800 [-] Server Shut Down.
2009-07-30 19:07:01+0800 [-] Log opened.
2009-07-30 19:07:01+0800 [-] twistd 8.2.0 (/usr/bin/python 2.4.3) starting up.
2009-07-30 19:07:01+0800 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2009-07-30 19:07:01+0800 [-] Starting factory
2009-07-30 19:07:01+0800 [Uninitialized] will retry in 2 seconds
2009-07-30 19:07:01+0800 [Uninitialized] Stopping factory
2009-07-30 19:07:04+0800 [-] Starting factory
2009-07-30 19:07:04+0800 [Uninitialized] will retry in 7 seconds
2009-07-30 19:07:04+0800 [Uninitialized] Stopping factory
2009-07-30 19:07:12+0800 [-] Starting factory
2009-07-30 19:07:12+0800 [Uninitialized] will retry in 21 seconds
2009-07-30 19:07:12+0800 [Uninitialized] Stopping factory
2009-07-30 19:07:34+0800 [-] Starting factory
2009-07-30 19:07:34+0800 [Uninitialized] will retry in 60 seconds
2009-07-30 19:07:34+0800 [Uninitialized] Stopping factory
2009-07-30 19:08:34+0800 [-] Starting factory
2009-07-30 19:08:34+0800 [Uninitialized] will retry in 172 seconds
2009-07-30 19:08:34+0800 [Uninitialized] Stopping factory
2009-07-30 19:11:27+0800 [-] Starting factory
2009-07-30 19:11:27+0800 [Uninitialized] will retry in 312 seconds
2009-07-30 19:11:27+0800 [Uninitialized] Stopping factory
2009-07-30 19:13:32+0800 [-] Received SIGTERM, shutting down.
2009-07-30 19:13:32+0800 [-] Main loop terminated.
2009-07-30 19:13:32+0800 [-] Server Shut Down.
2009-07-30 19:13:55+0800 [-] Log opened.
2009-07-30 19:13:55+0800 [-] twistd 8.2.0 (/usr/bin/python 2.4.3) starting up.
2009-07-30 19:13:55+0800 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2009-07-30 19:13:55+0800 [-] Starting factory
2009-07-30 19:13:55+0800 [Uninitialized] will retry in 2 seconds
2009-07-30 19:13:55+0800 [Uninitialized] Stopping factory
2009-07-30 19:13:57+0800 [-] Starting factory
2009-07-30 19:13:57+0800 [Uninitialized] will retry in 7 seconds
2009-07-30 19:13:57+0800 [Uninitialized] Stopping factory
2009-07-30 19:14:05+0800 [-] Starting factory
2009-07-30 19:14:05+0800 [Uninitialized] will retry in 20 seconds
2009-07-30 19:14:05+0800 [Uninitialized] Stopping factory
2009-07-30 19:14:25+0800 [-] Starting factory
2009-07-30 19:14:25+0800 [Uninitialized] will retry in 53 seconds
2009-07-30 19:14:25+0800 [Uninitialized] Stopping factory
2009-07-30 19:15:05+0800 [-] Received SIGTERM, shutting down.
2009-07-30 19:15:05+0800 [-] Main loop terminated.
2009-07-30 19:15:05+0800 [-] Server Shut Down.
Posted by Allen at July 29,2009 19:23
1. 你有寫怎麼 checkout 嗎??請參考 manual 設定
2. slave 也有 log,可以參考看看
3. 好像都是 starting factory 有問題,所以檢查 f1 看看?
Posted by elleryq at July 30,2009 00:07