CruiseControl.rb简称CC,是一个持续集成的工具,主要提供了基于版本管理工具(如Git、svn)感知变化或每天定时的持续集成,并提供持续集成报告、Email等等方式通知相关负责人,其要求是需要进行日构建的项目已编写好全自动的项目编译脚本(可基于Rake或Ant)。官网地址:http://cruisecontrolrb.thoughtworks.com/
到cruisecontrol-1.4.0.tgz所在目录,进行解压:
tar xvzf cruisecontrol-1.4.0.tgz
然后,进行重命名:
mv cruisecontrol-1.4.0 /usr/local/cruisecontrol
确保cruisecontrol有正确的访问权限:
chmod -R 777 /usr/local/cruisecontrol
接下来,添加一个项目。
进入cruisecontrol目录:
cd /usr/local/cruisecontrol/
添加项目:
./cruise add community --url http://192.168.38.11/svn/projects/trunk/***/*** --username *** --password ***
修改cruise_config.rb配置:
vim /root/.cruise/projects/community/cruise_config.rb
配置如下:
# Project-specific configuration for CruiseControl.rb Project.configure do |project| # Send email notifications about broken and fixed builds to [email protected], [email protected] (default: send to nobody) # project.email_notifier.emails = ['[email protected]', '[email protected]'] # Set email 'from' field to [email protected]: # project.email_notifier.from = '[email protected]' # Build the project by invoking rake task 'custom' # project.rake_task = 'custom' # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked, # current working directory is <em>[cruise data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh # in version control, it should be '../build_my_app.sh' instead project.build_command = 'sh ./community.sh' # Ping Subversion for new revisions every 5 minutes (default: 30 seconds) project.scheduler.polling_interval = 30.minutes end
community.sh内容如下:
cd /opt/projects/education if [ ! -d `date +%Y%m%d` ]; then mkdir `date +%Y%m%d` fi if [ ! -d /opt/projects/education/`date +%Y%m%d`/xuexi6 ]; then cp -R /root/.cruise/projects/community/work /opt/projects/education/`date +%Y%m%d`/xuexi6 else cd /opt/projects/education/`date +%Y%m%d`/xuexi6 svn up fi
添加其他项目,步骤同上。
现在,启动CruiseControl.rb:
/usr/local/cruisecontrol/cruise start -d
这样,你就可以通过http://localhost:3333访问了。