Daily build实践

Daily build 实践

Daily build 作为软件开发的最佳实践之一,微软甚至将它称为项目管理的心跳,可见其在软件开发中的重要作用。为什么会有这么高的评价? 除了平常提到的一些显著改进外,主要是因为实现 daily build 前有一些先决条件,即意味着你至少已经实现下列 scm 管理:

1. 源代码管理

2. 单元测试

3. 版本管理

4. bug 管理

在上述基础上进行的 daily build ,可以说是软件开发的一种习惯。刚开始可能会有所不适应,但逐渐变为一种习惯后,就离不开了。

Daily build 现在有很多流行的工具,比如说 final builder ,支持脚本编写,是很不错的工具。但是没有钱购买工具怎么办,其实简单使用脚本来编写一个批处理工具,来进行 daily build ,也可以基本实现 daily build 的功能。下面就已 source safe + delphi 为例,来实现 daily build 。

::Daily Build Script

::viery 2004/07/20

::Your project's path in VSS

set SSProject="$/Project1/Source"

::Your VSS username and password

set Username=Viery

set Password=password

::Path to VSS command line tool and the VSS DB you want to use.

set VSSPath="C:\Develop\Vss\win32\ss.exe"

set SSDIR=C:\develop\vss

::Path to the directory where you will be keeping the archive

set ArchivePath=C:\Project\build

::Path to the delphi executable.

set DelphiPath="C:\Program files\Borland\Delphi7\Bin\dcc32.exe"

::Path to library

set Delphi ="C:\Program files\Borland\Delphi7"

:: Delphi Project Name

set ProjectName=Project1

::LibPath

Set LibPath="C:\Program files\Borland\Delphi7\Lib; "

::Begin Code

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set strdate=%%C%%A%%B

mkdir %ArchivePath%%strdate%\ABC0DEF

cd %ArchivePath%%strdate%

%VSSPath% get %SSProject% -Y%Username%,%Password% -R -I-

%DelphiPath% -u%LibPath% -nc:\Project\build\dcu %ArchivePath%%strdate%%ProjectName%

::archive

::move to release location

::Label the files

%VSSPath% label %SSProject% -L%strdate% -Y%Username%,%Password% -I-

::send emails to all to report

以上就是一个基本的 daily build 脚本,实现的基本功能包括:

1. 从 source safe 中 get lastest version

2. 调用 delphi 编译,创建最新的版本

3. 将新版本发布到特定版本的目录

4. 压缩,发布,发送 email

5. 将最新的版本号 Label 源代码。

然后将此批处理在 windows 的调度任务里设定为每天晚上定时执行,即可实现简单的 daily build 管理。

从简单处着手, daily build ,最重要的是开始。

Published At
Categories with Web编程
comments powered by Disqus