持续集成 TeamCity 的配置与使用

摘要:
TeamCity提供一系列特性可以让团队快速实现持续继承:IDE工具集成、各种消息通知、各种报表、项目管理、编译,单元测试,自动发布等等,所有的这些,都是让你的团队快速享有持续继承带来的效率提升、高质量的软件保障。TeamCity提供一个支持20个BuildConfiguration+3个Agent的免费版本。

环境:实现自动编译与自动化测试,发布到远程服务器,环境 VS2015 +WIN2008R2

什么是TeamCity

TeamCity是由Jetbrains开发的一款功能强大的持续集成(Continue Integration)工具,包括服务器端和客户端,目前支持Java,.Net 等项目开发。 TeamCity提供一系列特性可以让团队快速实现持续继承:IDE工具集成、各种消息通知、各种报表、项目管理、编译,单元测试,自动发布等等,所有的这些,都是让你的团队快速享有持续继承带来的效率提升、高质量的软件保障。TeamCity提供一个支持20个Build Configuration+3个Agent的免费版本。

配置WebDeploy

Visual Studio 默认提供三种发布的方式,文件,FTP,WebDeploy;最方便的还是WebDeploy,它可以在Visual Studio中一键部署到服务器上,并且智能判断哪些文件是新增的,哪些是需要修改或删除的。

下载: http://www.iis.net/downloads/microsoft/web-deploy[ 安装IIS选中管理工具 ]
1.启用Remote connections ,打开IIS中Management Service,勾选Enable Remote connections
2.IIS中选择项目启用webdeploy,生成配置文件
3.VS发布选择webdeploy选项,导入步骤2的配置文件
具体配置:
http://edi.wang/post/2013/12/21/iis-webdeploy-on-ws2008r2

配置TeamCity

win环境下安装比较简单,一路NEXT即可,配置过程中有可能会遇到如下问题:

选择数据库

The MS SQL Server JDBC driver is not found in the C:ProgramDataJetBrainsTeamCitylibjdbc directory.
Download the driver from the Microsoft Download Center and follow the instructions and place the driver jar file into the C:ProgramDataJetBrainsTeamCitylibjdbc directory on the server.

默认是没有MSSQL驱动的,需要复制jdbc驱动到C:ProgramDataJetBrainsTeamCitylibjdbc目录[高版本的JDBC不可以]

Agent&MSBuildTools

Warning: No enabled compatible agents for this build configuration. Please register a build agent or tweak build configuration requirements.

默认Agent需要配置MSBuildTools14.0_x86_Path,需要安装MSBuildTools
http://stackoverflow.com/questions/20008861/team-city-unmet-requirement-msbuildtools12-0-x86-path-exists
Developer Tools Microsoft 生成工具 2015
https://www.microsoft.com/zh-CN/download/details.aspx?id=48159

创建项目

选择Create Project From URL重源码服务器上获取代码[git svn tfs等],Build Configurations 中我配置了两项

image

1.Build是编译源码

image

Triggers 配置每次有新的源码迁入时就编译一个版本

image

2.Deploy发布到测试服务器

/p:PublishProfile=WebDeploy.pubxml
/p:OutputPath=Release
/p:DeployOnBuild=True
/p:OutputPath=bin

image

Triggers 配置当第一步成功的时候触发

image

3.提交代码测试

此项目引用这台计算机上缺少的 NuGet 程序包。使用 NuGet 程序包还原可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 ..packagesMicrosoft.Net.Compilers.2.2.0uildMicrosoft.Net.Compilers.props。

启用nuget插件

image

默认会nuget获得第三方的包,可能因为nuget被墙的原因,需要多试几次下载有本地的环境就可以了

image

遇到的一些问题:

C:TeamCityuildAgentwork177ef13051171b3cxxxxxx.Interface.csproj(361, 3): error MSB4019: 未找到导入的项目“C:Program

Files (x86)MSBuildMicrosoftVisualStudiov14.0WebApplicationsMicrosoft.WebApplication.targets”。请确认 <Import> 声明中

的路径正确,且磁盘上存在该文件。C:Program Files (x86)MSBuildMicrosoftVisualStudio

解决方式:默认安装VS的机器拷贝C:Program Files (x86)MSBuildMicrosoftVisualStudio目录下的文件到安装TeamCity同样的目录下。

ControllersHomeControllerTest.cs(2, 17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the

namespace 'Microsoft' (are you missing an assembly reference?)
ControllersValuesControllerTest.cs(7, 17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the

namespace 'Microsoft' (are you missing an assembly reference?)
ControllersHomeControllerTest.cs(8, 6): error CS0246: The type or namespace name 'TestClass' could not be found (are you

missing a using directive or an assembly reference?)
ControllersHomeControllerTest.cs(11, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you

missing a using directive or an assembly reference?)

解决方式:去除VS自带的测试DLL ,可以使用NUnit代替,相应的代码名称也得替换下:

[TestFixture] 
public classHomeControllerTest { 
    [Test]
    public voidIndex() 
    {
        //排列 
        HomeController controller = newHomeController(); 
        //操作 
        ViewResult result = controller.Index() asViewResult; 
        //断言 
        Assert.IsNotNull(result); Assert.AreEqual("Home Page", result.ViewBag.Title);
    }
}

具体:http://www.cnblogs.com/ShineTan/archive/2012/03/26/2417475.html

C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0WebDeployMicrosoft.Web.Publishing.MSDeploy.Common.targets(55,

5): 打包/发布任务 Microsoft.Web.Publishing.Tasks.CreateProviderList 未能加载 Web Deploy 程序集。此计算机上未正确安装

Microsoft Web Deploy。建议安装 Microsoft Web Deploy v3 或更高版本

解决方式:安装TeamCity的服务器安装WebDeploy

C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0WebMicrosoft.Web.Publishing.targets(4276, 5): error

ERROR_CERTIFICATE_VALIDATION_FAILED: Web 部署任务失败。 (已使用指定的进程(“Web Management Service”)连接到远程计算机

(“192.168.xxx.xxx”),但未能验证服务器的证书。如果你信任该服务器,请再次连接并允许不信任的证书。 在以下位置了解更多信息:

http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CERTIFICATE_VALIDATION_FAILED。)

解决方式:WebDeploy配置文件增加如下配置(https://msdn.microsoft.com/en-us/library/ff398069.aspx)

<!--信任证书-->
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>

C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0WebMicrosoft.Web.Publishing.targets(4276, 5): error

ERROR_USER_UNAUTHORIZED: Web 部署任务失败。 (已使用 Web 管理服务连接到远程计算机(“192.168.xxx.xxx”),但未能授权。请确保你使

用了正确的用户名和密码、你连接的站点已存在并且凭据代表的用户有权访问该站点。 在以下位置了解更多信息:

http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED。)

解决方式:WebDeploy配置文件增加如下配置

<!--用户密码-->
<Password>xxxxxxxxxx</Password>

C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0TypeScriptMicrosoft.TypeScript.targets(195, 5): error MSB6003: The specified task executable "tsc.exe" could not be run. Could not find a part of the path 'C:Program Files (x86)Microsoft SDKsTypeScript'

解决方案:安装TypeScript

升级版本:cope 安装包按照提示输入 log 下的 token 即可完成

持续集成 TeamCity 的配置与使用第8张

REFER:

如何部署站点到指定的服务器上面

http://www.cnblogs.com/jiekzou/p/5257982.html
Nodejs开源项目里怎么样写测试、CI和代码测试覆盖率
https://cnodejs.org/topic/558df089ebf9c92d17e73358
用命令行脚本发布Azure网站
http://blchen.com/publish-azure-website-from-command-line-msbuild/
Jenkins搭建.NET自动编译测试与发布环境
http://blog.csdn.net/wangjia184/article/details/18365553
How to build ASP.NET applications in TeamCity with MSBuild Tools 2013 and .NET Framework 4.5 SDK
http://www.danmusk.com/how-to-build-asp-net-applications-in-teamcity-with-msbuild-tools-2013-and-net-framework-4-5-sdk/
Deploy ASP.NET projects from TeamCity with Web Deploy
http://www.danmusk.com/deploy-asp-net-projects-from-teamcity-with-web-deploy/
Continuous Integration & Delivery For GitHub With TeamCity
http://www.mehdi-khalili.com/continuous-integration-delivery-github-teamcity
How to: Edit Deployment Settings in Publish Profile (.pubxml) Files and the .wpp.targets File in Visual Studio Web Projects
https://msdn.microsoft.com/en-us/library/ff398069
Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong
https://channel9.msdn.com/Events/MIX/MIX10/FT14
Build ASP.NET 4.5 without Visual Studio on Build Server
http://stackoverflow.com/questions/12944502/build-asp-net-4-5-without-visual-studio-on-build-server
Team city unmet requirement: MSBuildTools12.0_x86_Path exists
http://stackoverflow.com/questions/20008861/team-city-unmet-requirement-msbuildtools12-0-x86-path-exists

https://nickcraver.com/blog/2016/05/03/stack-overflow-how-we-do-deployment-2016-edition/

https://octopus.com/

免责声明:文章转载自《持续集成 TeamCity 的配置与使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇痞子衡嵌入式:ARM Cortex-M内核那些事(5)- 一表搜罗指令集计算机启动过程下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

rocketmq-console 控制台使用详解

三、控制台的使用 1. 切换语言为简体中文 上图首页即为“驾驶舱”标签下的图标,中共有4个图:- Broker TOP 10 :是指前10个Brokder处理消息的数量。比如从上图可以看出来,我只有一个Brokder,并且此Brokder处理了1000条消息.- Broker 5min trend: 此图标可以筛选出某个Topic下5分钟的消息数量,可以...

【js学习】js连接RabbitMQ达到实时消息推送

js连接RabbitMQ达到实时消息推送 最近在自己捯饬一个网站,有一个功能是需要后端处理完数据把数据发布到MQ中,前端再从MQ中接收数据。但是前端连接MQ又成了一个问题,在网上搜了下资料,点进去一篇IBM DW后发现竟然是超哥写的,真是巧哈~因为超哥写的很好所以很多我就直接摘抄过来了,他应该不会介意的(逃。 参考 基于 RabbitMQ 的实时消息推送...

围观微博网友发起的美胸比赛学习爬取微博评论内容

网友:看看胸女:滚 网友:美胸比赛女:[图片消息] ​​​​ 继上次知乎话题 拥有一副好身材是怎样的体验? 解析了知乎回答内容之后,这次我们来解析一下微博内容,以微博网友发起的美胸大赛为例: https://m.weibo.cn/detail/4367970740108457 https://m.weibo.cn/detail/434802252095...

消息队列 RabbitMQ

  前言 市面上的消息队列产品有很多,比如老牌的 ActiveMQ、RabbitMQ ,目前我看最火的 Kafka ,还有 ZeroMQ ,阿里巴巴捐赠给 Apache 的 RocketMQ ,连 redis 这样的 NoSQL 数据库也支持 MQ 功能。总之这块知名的产品就有十几种。 什么是rabbitMQ RabbitMQ 是一个由 Erlang 语...

003.kubernets对于namespace的管理

一 Kuberbetes的架构简单介绍 1.1 云计算的传统分类 1.2 kubernetes基础架构 工作机制 用户通过kubectl向api-server提交需要运行的pod描述 api-server接收请求并将相关描述存储到etcd scheduler 监控api-server拿到相关描述信息,开始扫描node节点,找到满足条件的node节点...

RabbitMQ(四)Spring集成RabbitMQ

前言 在使用Spring整合RabbitMQ时我们主要关注三个核心接口: RabbitAdmin: 用于声明交换机 队列 绑定等 RabbitTemplate: 用于RabbitMQ消息的发送和接收 MessageListenerContainer: 监听容器 为消息入队提供异步处理 依赖 <dependency> &l...