Fork me on GitHub
 

在Ubuntu上安装Hudson, 配置CI测试Rails应用

05 February 2010

安装Hudson

参考 http://hudson-ci.org/debian/

  1. 加载apt key
    wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add -

  2. 修改apt源 /etc/apt/sources.list 加入
    deb http://hudson-ci.org/debian binary/

  3. 安装Hudson
    sudo apt-get update
    sudo apt-get install hudson

  4. 安装过程中会自动创建一个用户 hudson, 现在手动把hudson加入到git用户组中, 以便能够有权限clone出gitosis中的git项目 (hudson和gitosis是安装在同一台服务器上的) :
    sudo usermod -g git hudson

  5. 进入hudson帐号, 配置user.email和user.name
    sudo su hudson
    git config --global user.email "hudson@test"
    git config --global user.name "hudson"

安装完成后即可通过浏览器访问部署在8080端口的Hudson

Hudson Home hosted by Ember

为Hudson安装Git和Rake插件

用浏览器进入 “Manage Hudson” > “Manage Plugins” > “Available”, 找到 “GIT plugin” 和 “Rake plugin”, 选中后点击右下角 “Install” 安装

Hudson Install Plugins hosted by Ember

创建CI任务

  1. 选择Free-style模式
    Hudson New Job hosted by Ember

  2. 配置Git repo地址
    Hudson Git repo hosted by Ember

  3. 创建Rake测试任务
    Hudson Rake Cucumber hosted by Ember

配置git hooks, 每次提交代码后自动运行Hudson build

cd /home/git/repositories/xxxx.git/hooks
echo "curl -s http://[YOURHOST]:8080/job/[YOURAPP]/build" > post-update

Tags: ubuntu, hudson, ci, rails, git

About

"D" is for Dylan, this blog is about life and tech(computer world).
Feel free to contact me: d@hc.la