自构建工具TeamCity的安装及使用

来源:互联网 发布:网络统考成绩查询 编辑:程序博客网 时间:2024/06/13 19:27

自构建工具TeamCity的安装及使用


第2章 安装步骤


2.2 软件安装


2.2.1 安装包位置
\\192.168.0.5\persons\下载软件\TeamCity-8.1.5.exe 

附属安装包
\\192.168.0.5\persons\下载软件\WDeploy.exe

2.2.2 安装
点击 Teamcity-8.1.5.exe 按提示安装即可,安装完成后在安装目录有个文件加 TeamCity 
同时管理用的网站也配置好了

在浏览器输入配置的地址打开如下:http://localhost:8080/login.html

输入admin,admin (默认管理员帐号)(首次要求创建管理员帐号)



也可自己注册新帐号,注册好后联系管理员分配权限

登入后 点击 又上角的 administrator即可创建,管理用户,用户组等
 


2.2.3 WDeploy.exe web部署服务安装
WDeploy.exe 是微软的web部署工具,因为发布web站点时要用到,点击安装,自定义安装,勾选所有项进行安装即可。

安装完成后,进入控制面板-管理工具-服务,

MsDepSvc,WMSVC 这两个服务设为自动启动并启动,如下图:


 

第3章 软件使用

本例以***.Webapi的自构建为例说明如何配置管理项目

3.1 创建project

进入 administrator 如图:
 


点击 create project 进入创建页面
 


输入信息完成创建

3.2 配置project

点击左上角的 project 选下拉图标,选择刚创建的 project 如图:
 


点击项目右边的 下拉图标,选择 edit Settings 

3.2.1 General Settings 



上半部分可以修改


点击 Create Build configuration



创建完成后 在build list 里 点击 edit 进入 build 的配置页面
 


3.2.1..1 Build Configuration Setttings
General Settings
该部分信息可不用修改
Version Control Setting

该部分输入信息如下:


 

Build Steps

构建步骤分十步(dev),即添加十个build step,分别如下
1-4 步为nuget package还原
5-7 为 project 自动编译
8-10 为文档自动生成

第一步:
Runner type:选择合适的类型 nugget Installer
Step name : 自定义
Excute step 一般选 If all previous steps finished successfully 即可
Nugget Settings: default 2.8.3 没有这项从下面的 nugget settings 设置即可
Path to solution file: 选择需要还原nuget package 的解决方案



第二步:

同上,nuget一般以sln为单位;有个要注意的地方,如果解决方案下工程文件路径有调整最好在解决方案管理nuget包里把包的引用删除再添加下。否则会出现teamcity里编译找不到dll的问题

第三步:
同上

第四步:
同上

第五步:
Runner type:选择合适的类型 MSBuild
Step name : 自定义
Path to solution file: 选择需要编译的工程文件 csproj
MSBuild version : Microsoft Build Tools 2013
MSBuild ToolsVersion: 12.0
Run platform:x86
Targets: rebuild



Command line parameters: 
/p:ReferencePath="..\Lib\Public;..\Lib\Aliyun_dotnet_SDK\bin"
/p:Configuration=TestServer
/p:OutputPath=bin  
/p:DeployOnBuild=True  
/p:DeployTarget=MSDeployPublish  
/p:MsDeployServiceUrl=https://192.168.0.106:8172/msdeploy.axd  
/p:username=Administrator  
/p:password=***
/p:AllowUntrustedCertificate=True  
/p:DeployIisAppPath=webapi.dev
/p:MSDeployPublishMethod=WMSVC
/p:EnableMSDeployAppOffline=true 
/p:MSDeployUseChecksum=true

说明:
ReferencePath 除了nuget package 引用外的其它引用
Configuration 是配置 debug,release 还有自定义的配置可选
OutputPath 输出路径
MsDeployServiceUrl 里的IP 改成目标网站的ip
Username,password 为目标机器的帐号信息
DeployIisAppPath 为目标网站的网站名 iis中的网站名

.NET Coverage tool: <No .NET Coverage> 因为暂没做自动测试,故选择这个

这里一般是webapi的编译设置。

如果是vs2013建的网站项目,是没有proj文件的,可以在网站项目上发布网站,这样就会有website.publishproj 文件了,但这样的文件编译后有个问题,引用的第三方包及要用到的系统包不能编译进bin,本人通过手动修改website.publishproj文件解决。如下:

在itemgroup 加入要用到但没有的包(红色部分)

  <ItemGroup>
    <AssemblyAttributes Include="AssemblyFileVersion">
      <Value>$(AssemblyFileVersion)</Value>
    </AssemblyAttributes>
    <AssemblyAttributes Include="AssemblyVersion">
      <Value>$(AssemblyVersion)</Value>
    </AssemblyAttributes>
<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="MongoDB.Bson">
      <HintPath>..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Bson.dll</HintPath>
    </Reference>
    <Reference Include="MongoDB.Driver">
      <HintPath>..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Driver.dll</HintPath>
    </Reference>
<Reference Include="log4net">
      <HintPath>..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
    </Reference>
<Reference Include="AspNetPager">
      <HintPath>..\..\packages\AspNetPager.7.4.3\lib\AspNetPager.dll</HintPath>
    </Reference>

  </ItemGroup>

网站项目的build的paramline 设置如下:同webapi,略有一点点区别 /p:OutputPath=bin  不用设

/p:Configuration=Debug
/p:DeployOnBuild=True  
/p:DeployTarget=MSDeployPublish  
/p:MsDeployServiceUrl=https://192.168.1.9:8172/msdeploy.axd  
/p:username=Administrator  
/p:password=***
/p:AllowUntrustedCertificate=True  
/p:DeployIisAppPath=Promotion
/p:MSDeployPublishMethod=WMSVC
/p:EnableMSDeployAppOffline=true 
/p:MSDeployUseChecksum=true


第六步:


第七步:
同上

第八步:
 


/p:OutputPath="C:\Help\entity" 当输出路径与项目中不一致时可重新设置这个路径
*.shfbproj 是由Sandcastle Help File Build创建的项目 可参考 http://blog.csdn.net/huwei2003/article/details/42028163;主要用来根据代码注释自动生成文档

第九步
同上

第十步:
同上

Build step 是自构建设置中最重要也是最繁琐的一步,参照截图配置即可。


Tiggers

即设置触发构建的条件


 

Failure Contitions

无须设置

Build Features

无须设置

Dependencies
无须设置

Parameters

无须设置

Agent Requirements

无须设置,如图

3.2.2 VCS Roots

如图:同build step 里的版本库设置相同


3.2.3 Report Tabs

无须设置

3.2.4 Parameters

无须设置

补充:如果该组很多step的Command line parameters:一样或大到处相同,可以在参数这里统一设置,这样就不用每个step里都重复设置这个,如下:

下面是某个step Command line parameters内容:

/p:Configuration=Release/p:DeployOnBuild=True  /p:DeployTarget=MSDeployPublish  /p:MsDeployServiceUrl=https://192.168.1.147:8172/msdeploy.axd  /p:username=Administrator  /p:password=Admin123  /p:AllowUntrustedCertificate=True  /p:DeployIisAppPath=TL.Manager.Registry/p:MSDeployPublishMethod=WMSVC


把它设置到Parameters里,这样step里就不用设置了 Parameters里的设置如下:

System Properties (system.)Name Valuesystem.DefineConstants test147system.DeployIisAppPath %teamcity.build.step.name%system.MsDeployServiceUrl https://192.168.1.147:8172/msdeploy.axdsystem.password Adminsystem.username AdministratorEnvironment Variables (env.)Environment variables will be added to the environment of the processes launched by the build runner (without env. prefix). Environment Variables (env.) Name Valueenv.AllowUntrustedCertificate Trueenv.Configuration Releaseenv.DeployOnBuild Trueenv.DeployTarget MSDeployPublishenv.EnableMSDeployAppOffline trueenv.MSDeployPublishMethod WMSVCenv.MSDeployUseChecksum trueenv.OutputPath binenv.SkipExtraFilesOnServer True



所以创建工程的时候最好相同设置的分在同一工程,这样可以共享一样的设置

3.2.5 Builds Schedule

无须设置

3.2.6 Shared Resources

无须设置

3.2.7 Maven Settings

无须设置

3.2.8 Meta-Runners

无须设置


3.2.9 SSH Keys

无须设置


当以上都设置好后,只要版本库有代码跟新则会触发自动构建,构建完成后 成功会显示 success ,否则会显示 感叹号图标,点击可看错误原因。


0 0