TFS build server搭建,搭建自动化构建服务器
2015-01-20 15:48
302 查看
TFS build 服务器的搭建主要步骤如下:
一:环境准备:
新建一台build服务器
安装Visual Studio。主要目的是: a. 生成Build脚本所需要的build命令;b.与TFS组合,方便下载最新源代码
安装TFS。在Build Server触发build时,会通过tfs的命令从源代码服务器下载最新代码
安装InstallShield。通过InstallShield命令自动打包软件包
启动Visual Studio,手动Mapping源代码到build server本地目录。(供源代码下载使用)
二:脚本代码的编写(.bat),以下是bat脚本文件的工作流程
启用Visual Studio tool,这样就可以使用visual studio的命令。
删除本地的所有代码
从服务器下载最新的源代码
开始触发最新源代码的Build
开始触发InstallShield项目的build
把最新生成的软件包.exe上传到某个文件夹备用
checkout 项目源代码的版本文件并+1,大于9999则从1重新开始。
checkout InstallShield的版本文件并+1
checkin 以上两个文件,供下次使用。
三:编写一个计划任务,自动调用步骤二中的.bat脚本,完成build server的搭建
四:代码示例
以下是一个示例,共有两个文件,一个.bat文件,一个vbs文件。
.bat文件是整个build脚本的入口,负责整体build server脚本的流程和大部分的工作
.vbs文件主要是用来取出文件的版本信息;版本信息加1;并把新的版本号重新写入存储版本的文件
下面是这两个文件的代码,部分隐私信息已用*号处理
AutoBuildScript:
View Code
一:环境准备:
新建一台build服务器
安装Visual Studio。主要目的是: a. 生成Build脚本所需要的build命令;b.与TFS组合,方便下载最新源代码
安装TFS。在Build Server触发build时,会通过tfs的命令从源代码服务器下载最新代码
安装InstallShield。通过InstallShield命令自动打包软件包
启动Visual Studio,手动Mapping源代码到build server本地目录。(供源代码下载使用)
二:脚本代码的编写(.bat),以下是bat脚本文件的工作流程
启用Visual Studio tool,这样就可以使用visual studio的命令。
删除本地的所有代码
从服务器下载最新的源代码
开始触发最新源代码的Build
开始触发InstallShield项目的build
把最新生成的软件包.exe上传到某个文件夹备用
checkout 项目源代码的版本文件并+1,大于9999则从1重新开始。
checkout InstallShield的版本文件并+1
checkin 以上两个文件,供下次使用。
三:编写一个计划任务,自动调用步骤二中的.bat脚本,完成build server的搭建
四:代码示例
以下是一个示例,共有两个文件,一个.bat文件,一个vbs文件。
.bat文件是整个build脚本的入口,负责整体build server脚本的流程和大部分的工作
.vbs文件主要是用来取出文件的版本信息;版本信息加1;并把新的版本号重新写入存储版本的文件
下面是这两个文件的代码,部分隐私信息已用*号处理
AutoBuildScript:
If Wscript.Arguments.Count <> 2 Then WScript.Echo "Arguments Count Error" wscript.quit End If Set objFS = CreateObject("Scripting.FileSystemObject") 'version.h path versionFilePath=Wscript.Arguments(0) 'ProductNameeProductDriver.ism path driverFilePath=Wscript.Arguments(1) Dim newFileContent Dim newDriverContent Dim currentVersion Dim nextVersion 'Manually configure if needed. 'Below 5 variables is used for search the special version number 'This is used for search the postfix number 888 (e.g. 1.7.0.888) versionPostfixString="#define Product_INT_VERSION " 'This is used for search the prefix string 1.7.0 (e.g. 1.7.0.888) versionPrefixString="#define PACKAGE_VERSION " & chr(34) 'This is used for search the Product version number in ism file (e.g. 1.7.0.888) driverProductVersionPrefixString=" <row><td>ProductVersion</td><td>" 'This is used for search the EProduct version number in ism file (e.g. 1.7.0.888) driverEProductVersionPrefixString=" <row><td>EProductVERION</td><td>" 'the last charactor in the row (ism file) driverCommonPostfixString="</td><td/></row>" ' Auto Increase version.h file version number Set versionFile = objFS.OpenTextFile(versionFilePath) 'Read the lines one by one Do Until versionFile.AtEndOfStream strLine = versionFile.ReadLine ' Search if this line has versionPostfixString , Then get the postfix number and set the next number: nextVersionPostfix If InStr(strLine,versionPostfixString)> 0 Then versionPostfixLength=Len(strLine)-Len(versionPostfixString) versionPostfix=Right(strLine,versionPostfixLength) nextVersionPostfix=versionPostfix+1 If nextVersionPostfix>=1000 Then nextVersionPostfix=1 End If strLine = Replace(strLine,versionPostfix,nextVersionPostfix) End If 'Search if this line has versionPrefixString If InStr(strLine,versionPrefixString)> 0 Then versionPrefixLength=Len(strLine)-Len(versionPrefixString) versionPrefix=Right(strLine,versionPrefixLength) versionPrefix=Left(versionPrefix,versionPrefixLength-1) End If 'Store all the lines to newFileContent, it will be write to the version.h again. newFileContent = newFileContent & strLine & vbcrlf Loop versionFile.Close 'Write the new content to the version.h Set versionFile = objFS.OpenTextFile(versionFilePath,2) versionFile.Write newFileContent versionFile.Close currentVersion=versionPrefix & "." & versionPostfix nextVersion = versionPrefix & "." & nextVersionPostfix 'Auto increase driver version number Set driverFile = objFS.OpenTextFile(driverFilePath) 'Read the lines one by one Do Until driverFile.AtEndOfStream strLine = driverFile.ReadLine ' Search if this line has driverProductVersionPrefixString If InStr(strLine,driverProductVersionPrefixString)> 0 Then driverPreProductLength=Len(strLine)-Len(driverProductVersionPrefixString) driverLastVersionString=Right(strLine,driverPreProductLength) driverProductLength=Len(driverLastVersionString)-Len(driverCommonPostfixString) driverLastVersionString=Left(driverLastVersionString,driverProductLength) strLine = Replace(strLine,driverLastVersionString,nextVersion) End If 'Search if this line has driverEProductVersionPrefixString If InStr(strLine,driverEProductVersionPrefixString)> 0 Then driverPreEProductLength=Len(strLine)-Len(driverEProductVersionPrefixString) driverLastEProductVersionString=Right(strLine,driverPreEProductLength) driverEProductLength=Len(driverLastEProductVersionString)-Len(driverCommonPostfixString) driverLastEProductVersionString=Left(driverLastEProductVersionString,driverEProductLength) strLine = Replace(strLine,driverLastEProductVersionString,nextVersion) End If 'Store all the lines to newDriverContent, it will be write to the version.h again. newDriverContent = newDriverContent & strLine & vbcrlf Loop driverFile.Close 'Write the new content to the driver file Set driverFile = objFS.OpenTextFile(driverFilePath,2) driverFile.Write newDriverContent driverFile.Close 'This is the file version number, return to the result. WScript.Echo currentVersion
View Code
相关文章推荐
- ubuntu搭建subversion服务器, build svn server in ubuntu
- Windows Media Server搭建流媒体服务器
- 持续集成(持续构建)服务器luntbuild的一些配置细节
- 飞飞实验室:Ubuntu 9.04 Server 搭建Nginx+PHP5+MySQL完美Web服务器
- 在VMware中的Ubuntu Server搭建Java服务器环境(LAMT架构)
- VisualSVN Server搭建SVN服务器
- 持续集成(持续构建)服务器luntbuild的一些配置细节
- windows系统下HMailServer免费邮件服务器简易搭建 推荐
- 利用ISA Server 2006服务器阵列构建高性能、高可靠的企业防火墙
- Ubuntu Server搭建FTP服务器(3) --虚拟用户FTP服务器架设
- 教你用WSUS(Windows Server Update Services 3.0)搭建企业内部update服务器
- Linux下流媒体服务器的搭建(HelixServer)
- 安装用于 Team Foundation Server(单服务器部署)的 Microsoft Windows SharePoint Services ---TFS安装问题集
- Windows Media Server搭建流媒体服务器
- Cas-server服务器搭建3.3.1
- [转]linux下的fms2流媒体服务器搭建六部曲之三-----FlashMediaServer安装篇
- 邮件上网系统构建(二)服务器搭建
- Windows下搭建和配置Subversion服务器(CollabNetSubversion-server-1.5.4-1.win32.
- 用WSUS(Windows Server Update Services 3.0)搭建企业内部update服务器
- 使用VisualSVN Server搭建SVN服务器