Teamcity的安裝及使用

自構建工具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內容:

[plain] view plain copy
  1. /p:Configuration=Release  
  2. /p:DeployOnBuild=True    
  3. /p:DeployTarget=MSDeployPublish    
  4. /p:MsDeployServiceUrl=https://192.168.1.147:8172/msdeploy.axd    
  5. /p:username=Administrator    
  6. /p:password=Admin123    
  7. /p:AllowUntrustedCertificate=True    
  8. /p:DeployIisAppPath=TL.Manager.Registry  
  9. /p:MSDeployPublishMethod=WMSVC  


把它設置到Parameters裏,這樣step裏就不用設置了 Parameters裏的設置如下:

[plain] view plain copy
  1. System Properties (system.)  
  2. Name Value  
  3. system.DefineConstants test147  
  4. system.DeployIisAppPath %teamcity.build.step.name%  
  5. system.MsDeployServiceUrl https://192.168.1.147:8172/msdeploy.axd  
  6. system.password Admin  
  7. system.username Administrator  
  8. Environment Variables (env.)  
  9. Environment variables will be added to the environment of the processes launched by the build runner (without env. prefix).   
  10.   
  11.   
  12. Environment Variables (env.)   
  13. Name Value  
  14. env.AllowUntrustedCertificate True  
  15. env.Configuration Release  
  16. env.DeployOnBuild True  
  17. env.DeployTarget MSDeployPublish  
  18. env.EnableMSDeployAppOffline true  
  19. env.MSDeployPublishMethod WMSVC  
  20. env.MSDeployUseChecksum true  
  21. env.OutputPath bin  
  22. env.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 ,否則會顯示 感嘆號圖標,點擊可看錯誤原因。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章