TFS build server搭建,搭建自动化构建服务器
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:
@echo off ::Need to manually configure the Path
set VisualStudio2010Tool="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
set SourceCodeItemSpecPath="$/Company_1003/Product/dev/EGS/Product/source/Product/App/eProduct/eProduct-1.7.0/CLK/source/eProduct"
set InstallshieldCommandTool="C:\Program Files (x86)\InstallShield\2012\System\IsCmdBld.exe"
set TeamforgeProjectName="eProduct 1.7"
set TeamforgePackage="eProduct 1.7" ::Relative Path, Manually configure if needed
::SourceCodeFolder e.g. "C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct"
set SourceCodeFolder=%~f0\..\..\eProduct
set ForceDownloadLatestSourceCode=True
::BuildSolutionFile e.g."C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\2008sln\eProduct.sln"
set BuildSolutionFile=%~f0\..\..\eProduct\2008sln\eProduct.sln
::BuildModel e.g. Debug or Release
set BuildModel=Release
::eProductDriverProject e.g. "C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\ProductNameeProductDriver\ProductNameeProductDriver.ism"
set eProductDriverProject=%~f0\..\..\eProduct\ProductNameeProductDriver\ProductNameeProductDriver.ism
::TeamforgeUploadExecutableFile e.g. "C:\Data\SFEEUploadFiles\UploadFiles.exe"
set TeamforgeUploadExecutableFile=%~f0\..\SFEEUploadFiles\UploadFiles.exe
::DriverReleaseFilePath e.g. "C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\ProductNameeProductDriver\ProductNameeProductDriver\PROJECT_ASSISTANT\Release 1\DiskImages\DISK1"
set DriverReleaseFilePath="%~f0\..\..\eProduct\ProductNameeProductDriver\ProductNameeProductDriver\PROJECT_ASSISTANT\Release 1\DiskImages\DISK1"
::e.g "C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\libfsl\include\version.h"
set VersionFilePath=%~f0\..\..\eProduct\libfsl\include\version.h
::e.g. "C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\ProductNameeProductDriver\ProductNameeProductDriver.ism"
set DriverFilePath=%~f0\..\..\eProduct\ProductNameeProductDriver\ProductNameeProductDriver.ism
::e.g. C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\ProductNameeProductDriver\ProductNameeProductDriver\PROJECT_ASSISTANT\Interm\IsConfig.ini
set DriverConfigFilePath=%~f0\..\..\eProduct\ProductNameeProductDriver\ProductNameeProductDriver\PROJECT_ASSISTANT\Interm\IsConfig.ini
::e.g. C:\Code\eProduct1.7\eProduct-1.7.0\CLK\source\eProduct\Product\2008win32\
set eProductReleaseFilePath=%~f0\..\..\eProduct\Product\2008win32\
set ModifyVersionVBSFilePath=%~f0\..\autoincreaseversionnumber.vbs
set eProductDriverFilesPath=%~f0\..\..\eProduct\ProductNameeProductDriver\eProductDriverFiles
set eProductDriverCreatePath=%~f0\..\..\eProduct\Product\2008win32\Create @echo on echo Set the vs 2010 command tool as the default command prompt.
call %VisualStudio2010Tool% echo Start to download source code from TFS
if not exist %SourceCodeFolder% ( echo please maping the tfs source code to build server local folder
echo Build Failed.
exit )
echo Delete the old source code
rd %SourceCodeFolder%/s/q echo Downloading source code...
IF %ForceDownloadLatestSourceCode% EQU False (tf get %SourceCodeItemSpecPath% /recursive) ELSE (tf get %SourceCodeItemSpecPath% /all /recursive)
echo Download source code Finished. echo Start Build the solution
MSBuild %BuildSolutionFile% /property:Configuration=%BuildModel%
echo Build Finished. echo Start to build Installshield Project
tf checkout %DriverConfigFilePath% echo Copy files under Create folder to eProduct Driver installer
rd /s /q %eProductDriverFilesPath%
md %eProductDriverFilesPath%
xcopy /E /F /Y %eProductDriverCreatePath% %eProductDriverFilesPath% %InstallshieldCommandTool% -p %eProductDriverProject%
echo Build Installshield Project Finished echo Start checkout and increase version number, then checkin the increased version number tf checkout %VersionFilePath% %DriverFilePath% for /f "delims=" %%i in ('cscript //nologo %ModifyVersionVBSFilePath% %VersionFilePath% %DriverFilePath%') do set "d=%%i"
set TeamforgeVersion=%d% tf checkin %VersionFilePath% %DriverFilePath% /comment:"Build Server New Build on %TeamforgeVersion%" /noprompt /override:"Build Server Checkin" echo Start to Upload the Image files to Teamforge
set eProductReleaseUploadFile=%eProductReleaseFilePath%eProduct%TeamforgeVersion%.ZIP
if not exist %eProductReleaseUploadFile% ( echo Do not exist %eProductReleaseUploadFile%, maybe build solution failed.
echo Build Failed.
exit ) if not exist %DriverReleaseFilePath% ( echo Do not exist %DriverReleaseFilePath%, maybe build Driver Disk failed.
echo Build Failed.
exit ) %TeamforgeUploadExecutableFile% %eProductReleaseUploadFile% %TeamforgeProjectName% %TeamforgePackage% %TeamforgeVersion% "http://sourceforge.is.ad.Company.com/sf-soap43/services" "Cruise_Control" "Mikohn123"
%TeamforgeUploadExecutableFile% %DriverReleaseFilePath% %TeamforgeProjectName% %TeamforgePackage% %TeamforgeVersion% "http://sourceforge.is.ad.Company.com/sf-soap43/services" "Cruise_Control" "Mikohn123" echo Upload the Image files to Teamforge Finished echo Build Finished. exit
Auto Increase Version Number:
If Wscript.Arguments.Count <> Then
WScript.Echo "Arguments Count Error"
wscript.quit
End If Set objFS = CreateObject("Scripting.FileSystemObject")
'version.h path
versionFilePath=Wscript.Arguments()
'ProductNameeProductDriver.ism path
driverFilePath=Wscript.Arguments() 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()
'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)> Then
versionPostfixLength=Len(strLine)-Len(versionPostfixString)
versionPostfix=Right(strLine,versionPostfixLength)
nextVersionPostfix=versionPostfix+
If nextVersionPostfix>= Then
nextVersionPostfix=
End If
strLine = Replace(strLine,versionPostfix,nextVersionPostfix)
End If
'Search if this line has versionPrefixString
If InStr(strLine,versionPrefixString)> Then
versionPrefixLength=Len(strLine)-Len(versionPrefixString)
versionPrefix=Right(strLine,versionPrefixLength)
versionPrefix=Left(versionPrefix,versionPrefixLength-)
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,)
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)> 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)> 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,)
driverFile.Write newDriverContent
driverFile.Close 'This is the file version number, return to the result.
WScript.Echo currentVersion
TFS build server搭建,搭建自动化构建服务器的更多相关文章
- TFS2010单独安装配置tfs build server
记录一下确实很磨人. 同样硬件和软件环境的两台服务器,其中一台服务器很久之前就配置好了tfs2010 build ,然后最近想再配置一台tfs build server,但是按照以前的配置流程始终提示 ...
- 搭建yeoman自动化构建工具
yeoman可以快速的搭建一个项目的手脚架,初次接触yeoman,在搭建的过程中遇到了很多的问题. yeoman需要node.js(http://nodejs.org)和git(http://git- ...
- Jenkins+Ant+TestNG+Testlink自动化构建集成(完整版)
这段时间折腾自动化测试,之前都是在Eclipse工程里面手工执行自动化测试脚本,调用Testlink API执行测试用例,目前搭建Jenkins自动化构建测试的方式,实现持续构建,执行自动化测试. 硬 ...
- Jenkins+Ant+TestNG+Testlink自动化构建集成
这段时间折腾自动化测试,之前都是在Eclipse工程里面手工执行自动化测试脚本,调用Testlink API执行测试用例,目前搭建Jenkins自动化构建测试的方式,实现持续构建,执行自动化测试. 硬 ...
- 边缘化搭建 DotNet Core 2.1 自动化构建和部署环境(上)
写在前面 写这篇文章的缘由是由于笔者的对新兴技术方向有所追求,但个人资产有限,只能容许购买一台阿里云低配1核2G服务器.服务器上搭建了 Centos7 & Docker & Jenki ...
- 手把手0基础项目实战(一)——教你搭建一套可自动化构建的微服务框架(SpringBoot+Dubbo+Docker+Jenkins)...
原文:手把手0基础项目实战(一)--教你搭建一套可自动化构建的微服务框架(SpringBoot+Dubbo+Docker+Jenkins)... 本文你将学到什么? 本文将以原理+实战的方式,首先对& ...
- 使用Hudson搭建自动构建服务器
环境: ubuntu1404_x64 说明: 使用hudson和git搭建自动构建服务器的简单示例 安装hudson及相关插件 安装hudson 安装命令如下: sudo sh -c "ec ...
- 我是如何进行Spring MVC文档翻译项目的环境搭建、项目管理及自动化构建工作的
感兴趣的同学可以关注这个翻译项目 . 我的博客原文 和 我的Github 前段时间翻译的Spring MVC官方文档完成了第一稿,相关的文章和仓库可以点击以下链接.这篇文章,主要是总结一下这个翻译项目 ...
- Geoserver+Openlayers+MySQL设计思想,GeoServer服务器搭建(Docker构建镜像)
Geoserver+Openlayers+MySQL设计思想,GeoServer服务器搭建(Docker构建镜像) 一.geoserver+openlayers+mysql主要设计思想 1.1 Geo ...
随机推荐
- 使用juggle简化网络编程
常规的网络编程,在消息处理上大概会采用如下方式 struct msg{ int msg_id; int msg_len; //...msg_info }; 定义如上的消息结构 接收方接收后,按如上的消 ...
- Selenium chrome配置代理Python版
环境: windows 7 + Python 3.5.2 + Selenium 3.4.2 + Chrome Driver 2.29 + Chrome 58.0.3029.110 (64-bit) S ...
- 【Android Developers Training】 39. 获取文件信息
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...
- maven配置本地仓库(从本地仓库下载jar包到.m2仓库)
Windows-->preference 把你的settings.xml存到一个地方maven指向你的settings.xmlsettings.xml里的地址是你们 ...
- C# selecd,new,virtual,abstract与override
本文大部分内容摘自 <.NET开发专家·亮剑.NET : .NET深入体验与实战精要> 博主只是搬运工,不喜勿喷. 关于虚方法,抽象类这一部分一直不是太清楚,目前的工作中也接触不到这些. ...
- Spring IOC bean加载过程
首先我们不要在学习Spring的开始产生畏难情绪.Spring没有臆想的那么高深,相反,它帮我们再项目开发中制定项目框架,简化项目开发.它的主要功能是将项目开发中繁琐的过程流程化,模式化,使用户仅在固 ...
- hdu2413(二分+二分匹配)
题意:人和外星人星球大战,人总共有H个星球,外星人有A个星球,现在人要用飞船去打外星人的飞船,要求每个人类星球只能对战一个外星球,且每个星球都开始有己知的飞船数,不论是人或外星人的星球,并每个星球都有 ...
- MySQL缓存之Qcache与buffer pool对比
Q:innodb buffer pool和Qcache的缓存区别? A: 1.Qcacche缓存的是SQL语句及对应的结果集,缓存在内存,最简单的情况是SQL一直不重复,那Qcache的命令率肯定是0 ...
- if else 与switch case判断
基础数据类型(四类八种 ) 不能为null. 整数型 byte 取值范围2的8次方 short 取值范围2的16次方 int 取值范围2的32次方 一般用int long 取值范围2的64次方 浮点型 ...
- [C++ Calculator 项目] 初试
Calculator V1.0 注:这是一个C++计算器项目的初始部分. 大体功能简介: 能够输入一串数学表达式 逐字符扫描,提取数字和符号得到一组队列 逐行输出提取的符号与数字 实现代码如下: sc ...