I'm working with a small (4 person) development team on a C# project. I've proposed setting up a build machine which will do nightly builds and tests of the project, because I understand that this is a Good Thing. Trouble is, we don't have a whole lot of budget here, so I have to justify the expense to the powers that be. So I want to know:
我正在与一个C#项目的小型(4人)开发团队合作。我已经提议建立一个构建机器,它将对项目进行夜间构建和测试,因为我知道这是一件好事。麻烦的是,我们这里没有足够的预算,所以我必须证明费用是合理的。所以我想知道:
我需要什么样的工具/许可证?现在,我们使用Visual Studio和Smart Assembly来构建,并使用Perforce进行源代码控制。我是否需要其他东西,或者是否有相当于运行自动脚本的cron作业?
这究竟是什么让我得到了,除了表明构建破坏了?我应该在这个脚本运行的解决方案(sln文件)中设置测试项目,这样我可以测试特定的功能吗?目前,我们有两次这样的测试,因为我们没有时间(或坦率地说,经验)来进行良好的单元测试。
我需要什么样的硬件?
一旦构建完成并经过测试,将该构建放在ftp站点上还是采用其他方式进行内部访问是一种常见做法吗?我们的想法是这台机器进行构建,我们都去了它,但是如果必须的话可以进行调试构建。
我们应该多久进行一次这种构建?
如何管理空间?如果我们制作夜间版本,我们是否应该保留所有旧版本,或者在大约一周左右后开始抛弃它们?
I realize that this is a very large topic, and I'm just starting out. I couldn't find a duplicate of this question here, and if there's a book out there I should just get, please let me know.
我意识到这是一个非常大的话题,我刚刚开始。我在这里找不到这个问题的副本,如果那里有一本书我应该得到,请告诉我。
EDIT: I finally got it to work! Hudson is completely fantastic, and FxCop is showing that some features we thought were implemented were actually incomplete. We also had to change the installer type from Old-And-Busted vdproj to New Hotness WiX.
编辑:我终于开始工作了! Hudson非常精彩,FxCop表明我们认为实现的一些功能实际上是不完整的。我们还必须将安装程序类型从Old-And-Busted vdproj更改为New Hotness WiX。
Basically, for those who are paying attention, if you can run your build from the command line, then you can put it into hudson. Making the build run from the command line via MSBuild is a useful exercise in itself, because it forces your tools to be current.
基本上,对于那些正在关注的人,如果你可以从命令行运行你的构建,那么你可以把它放到哈德森。通过MSBuild从命令行运行构建本身就是一个很有用的练习,因为它会强制你的工具是最新的。
9 个解决方案
#1
Update: Jenkins is the most up to date version of Hudson. Everyone should be using Jenkins now. I'll be updating the links accordingly.
更新:Jenkins是Hudson的最新版本。现在每个人都应该使用Jenkins。我将相应地更新链接。
Hudson is free and extremely easy to configure and will easily run on a VM.
Hudson是免费的,非常容易配置,并且可以在VM上轻松运行。
Partly from an old post of mine:
部分来自我的一个老帖子:
We use it to
我们用它来
- Deploy Windows services
- Deploy web services
- Run MSTests & display as much information as any junit tests
- Keep track of low,med,high tasks
- trendgraph warnings and errors
部署Windows服务
部署Web服务
运行MSTests并显示与任何junit测试一样多的信息
跟踪低,中,高任务
趋势图警告和错误
Here are some of the built in .net stuff that Hudson supports
以下是Hudson支持的一些内置.net内容
- MSBuild
- NAnt
- MSTest
- Nunit
- Team Foundation Server
- fxcop
- stylecop
- compiler warnings
- code tasks
Team Foundation Server
Also, god forbid you are using visual source safe, it supports that as well. I'd recommend you take a look at Redsolo's article on building .net projects using Hudson
此外,上帝禁止你使用视觉源安全,它也支持它。我建议你看看Redsolo关于使用Hudson构建.net项目的文章
Your questions
-
Q: What kind of tools/licenses will I need? Right now, we use Visual Studio and Smart Assembly to build, and Perforce for source control. Will I need something else, or is there an equivalent of a cron job for running automated scripts?
问:我需要什么样的工具/许可证?现在,我们使用Visual Studio和Smart Assembly来构建,并使用Perforce进行源代码控制。我是否需要其他东西,或者是否有相当于运行自动脚本的cron作业?
-
A: I just installed visual studio on a fresh copy of a VM running a fresh, patched, install of a windows server OS. So you'd need the licenses to handle that. Hudson will install itself as a windows service and run on port 8080 and you will configure how often you want it to scan your code repository for updated code, or you can tell it to build at a certain time. All configurable through the browser.
答:我刚安装了一个运行全新,修补,安装的Windows服务器操作系统的虚拟机副本上的visual studio。所以你需要许可证来处理它。 Hudson将自己安装为Windows服务并在端口8080上运行,您将配置您希望它扫描代码存储库以获取更新代码的频率,或者您可以告诉它在特定时间构建。所有都可以通过浏览器配置。
-
Q: What, exactly, will this get me, other than an indication of a broken build? Should I set up test projects in this solution (sln file) that will be run by these scripts, so I can have particular functions tested? We have, at the moment, two such tests, because we haven't had the time (or frankly, the experience) to make good unit tests.
问:除了指示构建破坏之外,这究竟是什么让我感到满意?我应该在这个脚本运行的解决方案(sln文件)中设置测试项目,这样我可以测试特定的功能吗?目前,我们有两次这样的测试,因为我们没有时间(或坦率地说,经验)来进行良好的单元测试。
A: You will get an email on the first time a build fails, or becomes unstable. A build is unstable if a unit test fails or it can be marked unstable through any number of criteria that you set. When a unit test or build fails you will be emailed and it will tell you where, why and how it failed. With my configuration, we get:
答:您将在第一次构建失败时收到电子邮件,或者变得不稳定。如果单元测试失败,或者可以通过您设置的任何数量的标准将其标记为不稳定,则构建不稳定。当单元测试或构建失败时,您将通过电子邮件发送,它将告诉您失败的位置,原因和方式。通过我的配置,我们得到:
- list of all commits since the last working build
- commit notes of those commits
- list of files changed in the commits
- console output from the build itself, showing the error or test failure
自上次工作构建以来所有提交的列表
提交这些提交的注释
提交中更改的文件列表
来自构建本身的控制台输出,显示错误或测试失败
-
Q: What kind of hardware will I need for this?
问:我需要什么样的硬件?
A: A VM will suffice
答:虚拟机就足够了
-
Q: Once a build has been finished and tested, is it a common practice to put that build up on an ftp site or have some other way for internal access? The idea is that this machine makes the build, and we all go to it, but can make debug builds if we have to.
问:一旦构建完成并经过测试,通常的做法是将该构建放在ftp站点上还是有其他方式进行内部访问?我们的想法是这台机器进行构建,我们都去了它,但是如果必须的话可以进行调试构建。
A: Hudson can do whatever you want with it, that includes ID'ing it via the md5 hash, uploading it, copying it, archiving it, etc. It does this automatically and provides you with a long running history of build artifacts.
答:Hudson可以随心所欲地做任何事情,包括通过md5哈希进行ID,上传,复制,归档等等。它自动执行此操作并为您提供构建工件的长期运行历史记录。
-
Q: How often should we make this kind of build?
问:我们应该多久进行一次这种构建?
A: We have ours poll SVN every hour, looking for code changes, then running a build. Nightly is ok, but somewhat worthless IMO since what you've worked on yesterday wont be fresh in your mind in the morning when you get in.
答:我们每小时都会轮询SVN,寻找代码更改,然后运行构建。 Nightly是好的,但有点无价值的IMO,因为你昨天工作的东西在早上进入时不会在你脑海中浮现。
-
Q: How is space managed? If we make nightly builds, should we keep around all the old builds, or start to ditch them after about a week or so?
问:如何管理空间?如果我们制作夜间版本,我们是否应该保留所有旧版本,或者在大约一周左右后开始抛弃它们?
A: Thats up to you, after so long I move our build artifacts to long term storage or delete them, but all the data which is stored in text files / xml files I keep around, this lets me store the changelog, trend graphs, etc on the server with verrrry little space consumed. Also you can set Hudson up to only keep artifacts from a trailing # of builds
答:这取决于你,经过这么长时间我将构建工件移动到长期存储或删除它们,但是我保留的文本文件/ xml文件中存储的所有数据,这让我存储更改日志,趋势图,服务器上的等等,消耗了很少的空间。此外,您可以将Hudson设置为仅保留尾随的构建版本中的工件
-
Q: Is there anything else I'm not seeing here?
问:还有什么我没看到的吗?
A: No, Go get Hudson right now, you wont be disappointed!
答:不,现在去哈德森,你不会失望的!
#2
We've had great luck with the following combo:
我们在以下组合中运气很好:
- Visual Studio (specifically, using the MSBuild.exe command line tool and passing it our solution files. removes the need for msbuild scripts)
- NAnt (like the XML syntax/task library better than MSBuild. Also has options for P4 src control operations)
- CruiseControl.net - built in web dashboard for monitoring/starting builds.
Visual Studio(具体来说,使用MSBuild.exe命令行工具并将其传递给我们的解决方案文件。删除了对msbuild脚本的需求)
NAnt(比XML语法/任务库更好于MSBuild。还有P4 src控制操作的选项)
CruiseControl.net - 内置在Web仪表板中,用于监控/启动构建。
CCNet has built in notifiers to send emails when builds succeed/fail
CCNet内置通知程序,可在构建成功/失败时发送电子邮件
On justification: This takes the load off developers doing manual builds and does a lot to take human error out of the equation. It is very hard to quantify this effect, but once you do it you will never go back. Having a repeatable process to build and release software is paramount. I'm sure you've been places where they build the software by hand and it gets out in the wild, only to have your build guy say "Oops, I must have forgotten to include that new DLL!"
在理由上:这会减轻开发人员进行手动构建的负担,并且可以将人为错误排除在外。很难量化这种效果,但一旦你这样做,你将永远不会回去。拥有可重复的过程来构建和发布软件是至关重要的。我确信你已经成为他们手工构建软件的地方,并且它会在野外出现,只是让你的构建人员说“哎呀,我一定忘了包含那个新的DLL!”
On hardware: as powerful as you can get. More power/memory = faster build times. If you can afford it you'll never regret getting a top-notch build machine, no matter how small the group.
在硬件上:尽可能强大。更多功率/内存=更快的构建时间。如果你负担得起,无论团队多么小,你都不会后悔获得一流的制造机器。
On space: Helps to have plenty of hard disk space. You can craft your NAnt scripts to delete intermediate files every time a build starts, so the real issue is keeping log histories and old application installers. We have software that monitors disk space and sends alerts. Then we clean up the drive manually. Usually needs to be done every 3-4 months.
在空间:有助于拥有足够的硬盘空间。您可以制作NAnt脚本以在每次构建开始时删除中间文件,因此真正的问题是保留日志历史记录和旧的应用程序安装程序。我们有监控磁盘空间并发送警报的软件。然后我们手动清理驱动器。通常需要每3-4个月完成一次。
On build notifications: This is built in to CCNet, but if you are going to add automated testing as an additional step then build this into the project from the get-go. It is extremely hard to back fit tests once a project gets large. There is tons of info on test frameworks out there (probably a ton of info on SO as well), so I'll defer on naming any specific tools.
关于构建通知:这是内置于CCNet的,但如果您要添加自动化测试作为额外步骤,那么从一开始就将其构建到项目中。一旦项目变大,就很难回溯测试。有很多关于测试框架的信息(可能还有关于SO的大量信息),因此我将推迟命名任何特定工具。
#3
At my previous workplace we used TeamCity. It's very easy and powerful to use. It can be used for free with some restrictions. There is also a tutorial on Dime Casts. The reason we didn't use CruiseControl.NET is that we had a lot of small projects and it's quite painful to set each one up in CC.NET. I would highly recommend TeamCity. To summarize if you are toward open source then CC.NET is the grand daddy with slightly higher learning curve. If your budget allow you definitely go with TeamCity or check out the free version.
在我之前的工作场所,我们使用了TeamCity。它使用起来非常简单和强大。它可以免费使用,但有一些限制。还有一个关于Dime Casts的教程。我们没有使用CruiseControl.NET的原因是我们有很多小项目,在CC.NET中设置每个项目都非常痛苦。我强烈推荐TeamCity。总结一下,如果你是开源软件,那么CC.NET就是那个学习曲线略高的大爸爸。如果您的预算允许您使用TeamCity或查看免费版本。
#4
How? Have a look at Carel Lotz's blog.
怎么样?看看Carel Lotz的博客。
Why? There are several reasons that I can think of:
为什么?我能想到几个原因:
- A working build, when properly implemented, means that all your developers can build on their machine when the build is green
- A working build, when properly implemented, means that you are ready to deploy at any time
- A working build, when properly implemented, means that whatever you release has made a trip to your source control system.
- A working build, when properly implemented, means that you integrate early and often, reducing your integration risk.
正确实现的工作构建意味着当构建为绿色时,所有开发人员都可以在其计算机上构建
正确实施的工作构建意味着您随时可以部署
正确实施的工作构建意味着您发布的任何内容都会使您的源控制系统脱颖而出。
正确实施的工作构建意味着您可以尽早和经常集成,从而降低集成风险。
Martin Fowler's article on Continuous Integration remains the definitive text. Have a look at it!
Martin Fowler关于持续整合的文章仍然是权威文本。看看它!
#5
The main argument in favour is that it will cut the cost of your development process, by alerting you as soon as possible that you have a broken build or failing tests.
支持的主要理由是,它会尽快提醒您有一个破坏的构建或失败的测试,从而降低了开发过程的成本。
The problem of integrating the work of multiple developers is the main danger of growing a team. The larger the team gets, the harder it is to coordinate their work and stop them messing with each other's changes. The only good solution is to tell them to "integrate early and often", by checking in small units of work (sometimes called "stories") as they are completed.
整合多个开发人员的工作的问题是团队成长的主要危险。团队越大,就越难协调他们的工作并阻止他们搞乱彼此的变化。唯一的好办法是告诉他们“尽早和经常融合”,通过检查完成后的小工作单元(有时称为“故事”)。
You should make the build machine rebuild EVERY time some checks in, throughout the day. With Cruise Control, you can get an icon on your task bar that turns red (and even talks to you!) when the build is broken.
您应该在一天中进行一些检查时使构建机器重建。使用Cruise Control,您可以在任务栏上获得一个图标,当构建中断时,该图标会变为红色(甚至会与您交谈!)。
You should then do a nightly full clean build where the source version is labeled (given a unique build number) that you can choose to publish to your stakeholders (product managers, QA people). This is so that when a bug is reported, it is against a known build number (that's extremely important).
然后,您应该进行每晚全面清理构建,其中标记了源版本(给定唯一的内部版本号),您可以选择将其发布给您的利益相关者(产品经理,QA人员)。这是因为当报告错误时,它是针对已知的构建号(这是非常重要的)。
Ideally you should have an internal site where builds can be downloaded, and have a button you can click to publish the previous nightly build.
理想情况下,您应该有一个内部站点,可以下载构建,并有一个按钮,您可以单击以发布以前的每晚构建。
#6
Just trying to build a bit on what mjmarsh said, since he laid a great foundation...
试着建立一下mjmarsh说的话,因为他奠定了坚实的基础......
- Visual Studio. MSBuild works fine.
- NAnt.
- NantContrib. This will provide additional tasks such as Perforce operations.
- CruiseControl.net. This is again basically your "build dashboard".
视觉工作室。 MSBuild工作正常。
NantContrib。这将提供其他任务,例如Perforce操作。
CruiseControl.net。这基本上就是你的“构建仪表板”。
All of the above (save for VS) is open source, so you're not looking at any additional licensing.
以上所有(除VS之外)都是开源的,因此您不会考虑任何其他许可。
As Earwicker mentioned, build early, build often. Knowing something broke, and you can produce a deliverable is useful for catching stuff early on.
正如Earwicker所说,早建,经常建造。知道某些事情已经破裂了,你可以制作一个可交付成果对于早期捕捉东西很有用。
NAnt includes tasks for nunit/nunit2 as well, so you can actually automate your unit testing. You can then apply stylesheets to the results, and with the help of the framework provided by CruiseControl.net, have nice readable, printable unit test results for every build.
NAnt还包括nunit / nunit2的任务,因此您可以实际自动化单元测试。然后,您可以将样式表应用于结果,并在CruiseControl.net提供的框架的帮助下,为每个构建提供可读的,可打印的单元测试结果。
The same applies to the ndoc task. Have your documentation produced and available, for every build.
这同样适用于ndoc任务。为每个构建生成并提供您的文档。
You can even use the exec task to execute other commands, for instance, producing a Windows Installer using InstallShield.
您甚至可以使用exec任务执行其他命令,例如,使用InstallShield生成Windows Installer。
The idea is to automate the build as much as possible, because human beings make mistakes. Time spent up front is time saved down the road. People aren't having to babysit the build by going through the build process. Identify all the steps of your build, create NAnt scripts for each task, and build your NAnt scripts one by one until you've wholly automated your entire build process. It also then puts all of your builds in one place, which is good for comparison purposes. Something break in Build 426 that worked fine in Build 380? Well, there are the deliverables ready for testing -- grab them and test away.
我们的想法是尽可能地自动化构建,因为人类会犯错误。预先花费的时间是在路上节省的时间。人们不必通过构建过程来照看构建。确定构建的所有步骤,为每个任务创建NAnt脚本,并逐个构建您的NAnt脚本,直到您完全自动化整个构建过程。然后它还将所有构建放在一个位置,这有利于比较。 Build 426中的一些东西在Build 380中运行良好吗?好吧,有可交付的产品可供测试 - 抓住它们并进行测试。
#7
- No licenses needed. CruiseControl.net is freely available and only needs the .NET sdk to build.
- A build server, even without automated unit tests still provides a controlled environment for building releases. No more "John usually builds on his machine but he's out sick. For some reason I can't build on my machine"
- Right now I have one set up in a Virtual PC session.
- Yes. The build needs to be dumped somewhere accessible. Development builds should have debugging turned on. Release build should have it turned off.
- How often is up to you. If set up correctly, you can build after each check in will very little overhead. This is a great idea if you have (or are planning on having) unit tests in place.
- Keep milestones and releases as long as required. Anything else depends on how often you build: continuously? throw away. Daily? Keep a week's worth. Weekly? Keep two month's worth.
无需许可证。 CruiseControl.net是免费提供的,只需要构建.NET sdk。
构建服务器即使没有自动化单元测试,仍然可以为构建版本提供受控环境。没有更多“约翰通常建立在他的机器上,但他生病了。出于某种原因,我不能在我的机器上建造”
现在我在Virtual PC会话中设置了一个。
是。构建需要转储到可访问的地方。开发版本应该打开调试。发布版本应该关闭它。
多久由你自己决定。如果设置正确,您可以在每次检入后构建很少的开销。如果您已经(或正在计划进行)单元测试,这是一个好主意。
只要需要,就可以保留里程碑和版本。还有什么取决于你建立的频率:持续不断?丢弃。日常?保持一周的价值。每周?保持两个月的价值。
The larger your project gets the more you will see the benefits of an automated build machine.
项目越大,您就越能看到自动构建机器的好处。
#8
It is all about the health of the build. What this gets you is that you can set up any type of things you want to happen with the builds. Among these you can run tests, static analysis, and profiler. Problems are dealt with much much faster, when you recently worked on that part of the application. If you commit small changes, then it almost tells you where you broke it :)
这完全取决于构建的健康状况。这会让你获得的是你可以设置你想要在构建中发生的任何类型的事情。在这些中,您可以运行测试,静态分析和分析器。当您最近处理应用程序的这一部分时,问题的处理速度要快得多。如果您进行小的更改,那么它几乎会告诉您在哪里打破它:)
This of course assumes, you set it up to build with every check in (continuous integration).
当然,假设您将其设置为每次检入时都进行构建(持续集成)。
It also can help get QA and Dev closer. As you can set up functional tests to run with it, along with profiler and anything else that improves feedback to the dev team. This doesn't mean the functional tests run with every check in (can take a while), but you set up builds/tests with tools that are common to the whole team. I have been automating smoke tests, so in my case we collaborate even more closely.
它还可以帮助QA和Dev更接近。您可以设置功能测试以与其一起运行,以及分析器和其他任何可以改善开发团队反馈的内容。这并不意味着每次签入都会运行功能测试(可能需要一段时间),但是您可以使用整个团队通用的工具来设置构建/测试。我一直在自动化烟雾测试,所以在我的情况下,我们更紧密地合作。
#9
Why: 10 years ago we as software developers used to analyse something to the nth degree get the documents (written in a human language) 'signed off' then start writing code. We would unit test, string test and then we would hit system test: the first time the system as a whole would be run together, sometimes week or months after we got the documents signed off. It was only then that we would uncover all the assumptions and misunderstandings we had when we analysed everything.
为什么:10年前我们作为软件开发人员用来分析某些东西到第n级获取文档(用人类语言编写)'签名'然后开始编写代码。我们将进行单元测试,字符串测试,然后我们将进行系统测试:第一次整个系统将一起运行,有时是在我们签署文件后的一周或几个月。只有到那时我们才会发现我们分析所有内容时所有的假设和误解。
Continuous Integration as and idea causes you to build a complete (although, initially, very simple) system end to end. Over time the system functionality is built out orthogonally. Every time you do a complete build you are doing the system test early and often. This means you find and fix bugs and assumptions as early as possible, when it is the cheapest time to fix them.
持续集成和想法使您构建一个完整的(尽管最初非常简单)系统端到端。随着时间的推移,系统功能正交建立。每次完成构建时,您都会尽早并经常进行系统测试。这意味着您可以尽早找到并修复错误和假设,这是修复它们的最便宜的时间。
How: As for the how, I blogged about this a little while ago:[ Click Here]
方法:至于如何,我不久前在博客上发表了这篇文章:[点击这里]
Over 8 posts it goes step by step on how to set up a Jenkins server in a windows environment for .NET solutions.
超过8个帖子逐步介绍了如何在Windows环境中为.NET解决方案设置Jenkins服务器。
#1
Update: Jenkins is the most up to date version of Hudson. Everyone should be using Jenkins now. I'll be updating the links accordingly.
更新:Jenkins是Hudson的最新版本。现在每个人都应该使用Jenkins。我将相应地更新链接。
Hudson is free and extremely easy to configure and will easily run on a VM.
Hudson是免费的,非常容易配置,并且可以在VM上轻松运行。
Partly from an old post of mine:
部分来自我的一个老帖子:
We use it to
我们用它来
- Deploy Windows services
- Deploy web services
- Run MSTests & display as much information as any junit tests
- Keep track of low,med,high tasks
- trendgraph warnings and errors
部署Windows服务
部署Web服务
运行MSTests并显示与任何junit测试一样多的信息
跟踪低,中,高任务
趋势图警告和错误
Here are some of the built in .net stuff that Hudson supports
以下是Hudson支持的一些内置.net内容
- MSBuild
- NAnt
- MSTest
- Nunit
- Team Foundation Server
- fxcop
- stylecop
- compiler warnings
- code tasks
Team Foundation Server
Also, god forbid you are using visual source safe, it supports that as well. I'd recommend you take a look at Redsolo's article on building .net projects using Hudson
此外,上帝禁止你使用视觉源安全,它也支持它。我建议你看看Redsolo关于使用Hudson构建.net项目的文章
Your questions
-
Q: What kind of tools/licenses will I need? Right now, we use Visual Studio and Smart Assembly to build, and Perforce for source control. Will I need something else, or is there an equivalent of a cron job for running automated scripts?
问:我需要什么样的工具/许可证?现在,我们使用Visual Studio和Smart Assembly来构建,并使用Perforce进行源代码控制。我是否需要其他东西,或者是否有相当于运行自动脚本的cron作业?
-
A: I just installed visual studio on a fresh copy of a VM running a fresh, patched, install of a windows server OS. So you'd need the licenses to handle that. Hudson will install itself as a windows service and run on port 8080 and you will configure how often you want it to scan your code repository for updated code, or you can tell it to build at a certain time. All configurable through the browser.
答:我刚安装了一个运行全新,修补,安装的Windows服务器操作系统的虚拟机副本上的visual studio。所以你需要许可证来处理它。 Hudson将自己安装为Windows服务并在端口8080上运行,您将配置您希望它扫描代码存储库以获取更新代码的频率,或者您可以告诉它在特定时间构建。所有都可以通过浏览器配置。
-
Q: What, exactly, will this get me, other than an indication of a broken build? Should I set up test projects in this solution (sln file) that will be run by these scripts, so I can have particular functions tested? We have, at the moment, two such tests, because we haven't had the time (or frankly, the experience) to make good unit tests.
问:除了指示构建破坏之外,这究竟是什么让我感到满意?我应该在这个脚本运行的解决方案(sln文件)中设置测试项目,这样我可以测试特定的功能吗?目前,我们有两次这样的测试,因为我们没有时间(或坦率地说,经验)来进行良好的单元测试。
A: You will get an email on the first time a build fails, or becomes unstable. A build is unstable if a unit test fails or it can be marked unstable through any number of criteria that you set. When a unit test or build fails you will be emailed and it will tell you where, why and how it failed. With my configuration, we get:
答:您将在第一次构建失败时收到电子邮件,或者变得不稳定。如果单元测试失败,或者可以通过您设置的任何数量的标准将其标记为不稳定,则构建不稳定。当单元测试或构建失败时,您将通过电子邮件发送,它将告诉您失败的位置,原因和方式。通过我的配置,我们得到:
- list of all commits since the last working build
- commit notes of those commits
- list of files changed in the commits
- console output from the build itself, showing the error or test failure
自上次工作构建以来所有提交的列表
提交这些提交的注释
提交中更改的文件列表
来自构建本身的控制台输出,显示错误或测试失败
-
Q: What kind of hardware will I need for this?
问:我需要什么样的硬件?
A: A VM will suffice
答:虚拟机就足够了
-
Q: Once a build has been finished and tested, is it a common practice to put that build up on an ftp site or have some other way for internal access? The idea is that this machine makes the build, and we all go to it, but can make debug builds if we have to.
问:一旦构建完成并经过测试,通常的做法是将该构建放在ftp站点上还是有其他方式进行内部访问?我们的想法是这台机器进行构建,我们都去了它,但是如果必须的话可以进行调试构建。
A: Hudson can do whatever you want with it, that includes ID'ing it via the md5 hash, uploading it, copying it, archiving it, etc. It does this automatically and provides you with a long running history of build artifacts.
答:Hudson可以随心所欲地做任何事情,包括通过md5哈希进行ID,上传,复制,归档等等。它自动执行此操作并为您提供构建工件的长期运行历史记录。
-
Q: How often should we make this kind of build?
问:我们应该多久进行一次这种构建?
A: We have ours poll SVN every hour, looking for code changes, then running a build. Nightly is ok, but somewhat worthless IMO since what you've worked on yesterday wont be fresh in your mind in the morning when you get in.
答:我们每小时都会轮询SVN,寻找代码更改,然后运行构建。 Nightly是好的,但有点无价值的IMO,因为你昨天工作的东西在早上进入时不会在你脑海中浮现。
-
Q: How is space managed? If we make nightly builds, should we keep around all the old builds, or start to ditch them after about a week or so?
问:如何管理空间?如果我们制作夜间版本,我们是否应该保留所有旧版本,或者在大约一周左右后开始抛弃它们?
A: Thats up to you, after so long I move our build artifacts to long term storage or delete them, but all the data which is stored in text files / xml files I keep around, this lets me store the changelog, trend graphs, etc on the server with verrrry little space consumed. Also you can set Hudson up to only keep artifacts from a trailing # of builds
答:这取决于你,经过这么长时间我将构建工件移动到长期存储或删除它们,但是我保留的文本文件/ xml文件中存储的所有数据,这让我存储更改日志,趋势图,服务器上的等等,消耗了很少的空间。此外,您可以将Hudson设置为仅保留尾随的构建版本中的工件
-
Q: Is there anything else I'm not seeing here?
问:还有什么我没看到的吗?
A: No, Go get Hudson right now, you wont be disappointed!
答:不,现在去哈德森,你不会失望的!
#2
We've had great luck with the following combo:
我们在以下组合中运气很好:
- Visual Studio (specifically, using the MSBuild.exe command line tool and passing it our solution files. removes the need for msbuild scripts)
- NAnt (like the XML syntax/task library better than MSBuild. Also has options for P4 src control operations)
- CruiseControl.net - built in web dashboard for monitoring/starting builds.
Visual Studio(具体来说,使用MSBuild.exe命令行工具并将其传递给我们的解决方案文件。删除了对msbuild脚本的需求)
NAnt(比XML语法/任务库更好于MSBuild。还有P4 src控制操作的选项)
CruiseControl.net - 内置在Web仪表板中,用于监控/启动构建。
CCNet has built in notifiers to send emails when builds succeed/fail
CCNet内置通知程序,可在构建成功/失败时发送电子邮件
On justification: This takes the load off developers doing manual builds and does a lot to take human error out of the equation. It is very hard to quantify this effect, but once you do it you will never go back. Having a repeatable process to build and release software is paramount. I'm sure you've been places where they build the software by hand and it gets out in the wild, only to have your build guy say "Oops, I must have forgotten to include that new DLL!"
在理由上:这会减轻开发人员进行手动构建的负担,并且可以将人为错误排除在外。很难量化这种效果,但一旦你这样做,你将永远不会回去。拥有可重复的过程来构建和发布软件是至关重要的。我确信你已经成为他们手工构建软件的地方,并且它会在野外出现,只是让你的构建人员说“哎呀,我一定忘了包含那个新的DLL!”
On hardware: as powerful as you can get. More power/memory = faster build times. If you can afford it you'll never regret getting a top-notch build machine, no matter how small the group.
在硬件上:尽可能强大。更多功率/内存=更快的构建时间。如果你负担得起,无论团队多么小,你都不会后悔获得一流的制造机器。
On space: Helps to have plenty of hard disk space. You can craft your NAnt scripts to delete intermediate files every time a build starts, so the real issue is keeping log histories and old application installers. We have software that monitors disk space and sends alerts. Then we clean up the drive manually. Usually needs to be done every 3-4 months.
在空间:有助于拥有足够的硬盘空间。您可以制作NAnt脚本以在每次构建开始时删除中间文件,因此真正的问题是保留日志历史记录和旧的应用程序安装程序。我们有监控磁盘空间并发送警报的软件。然后我们手动清理驱动器。通常需要每3-4个月完成一次。
On build notifications: This is built in to CCNet, but if you are going to add automated testing as an additional step then build this into the project from the get-go. It is extremely hard to back fit tests once a project gets large. There is tons of info on test frameworks out there (probably a ton of info on SO as well), so I'll defer on naming any specific tools.
关于构建通知:这是内置于CCNet的,但如果您要添加自动化测试作为额外步骤,那么从一开始就将其构建到项目中。一旦项目变大,就很难回溯测试。有很多关于测试框架的信息(可能还有关于SO的大量信息),因此我将推迟命名任何特定工具。
#3
At my previous workplace we used TeamCity. It's very easy and powerful to use. It can be used for free with some restrictions. There is also a tutorial on Dime Casts. The reason we didn't use CruiseControl.NET is that we had a lot of small projects and it's quite painful to set each one up in CC.NET. I would highly recommend TeamCity. To summarize if you are toward open source then CC.NET is the grand daddy with slightly higher learning curve. If your budget allow you definitely go with TeamCity or check out the free version.
在我之前的工作场所,我们使用了TeamCity。它使用起来非常简单和强大。它可以免费使用,但有一些限制。还有一个关于Dime Casts的教程。我们没有使用CruiseControl.NET的原因是我们有很多小项目,在CC.NET中设置每个项目都非常痛苦。我强烈推荐TeamCity。总结一下,如果你是开源软件,那么CC.NET就是那个学习曲线略高的大爸爸。如果您的预算允许您使用TeamCity或查看免费版本。
#4
How? Have a look at Carel Lotz's blog.
怎么样?看看Carel Lotz的博客。
Why? There are several reasons that I can think of:
为什么?我能想到几个原因:
- A working build, when properly implemented, means that all your developers can build on their machine when the build is green
- A working build, when properly implemented, means that you are ready to deploy at any time
- A working build, when properly implemented, means that whatever you release has made a trip to your source control system.
- A working build, when properly implemented, means that you integrate early and often, reducing your integration risk.
正确实现的工作构建意味着当构建为绿色时,所有开发人员都可以在其计算机上构建
正确实施的工作构建意味着您随时可以部署
正确实施的工作构建意味着您发布的任何内容都会使您的源控制系统脱颖而出。
正确实施的工作构建意味着您可以尽早和经常集成,从而降低集成风险。
Martin Fowler's article on Continuous Integration remains the definitive text. Have a look at it!
Martin Fowler关于持续整合的文章仍然是权威文本。看看它!
#5
The main argument in favour is that it will cut the cost of your development process, by alerting you as soon as possible that you have a broken build or failing tests.
支持的主要理由是,它会尽快提醒您有一个破坏的构建或失败的测试,从而降低了开发过程的成本。
The problem of integrating the work of multiple developers is the main danger of growing a team. The larger the team gets, the harder it is to coordinate their work and stop them messing with each other's changes. The only good solution is to tell them to "integrate early and often", by checking in small units of work (sometimes called "stories") as they are completed.
整合多个开发人员的工作的问题是团队成长的主要危险。团队越大,就越难协调他们的工作并阻止他们搞乱彼此的变化。唯一的好办法是告诉他们“尽早和经常融合”,通过检查完成后的小工作单元(有时称为“故事”)。
You should make the build machine rebuild EVERY time some checks in, throughout the day. With Cruise Control, you can get an icon on your task bar that turns red (and even talks to you!) when the build is broken.
您应该在一天中进行一些检查时使构建机器重建。使用Cruise Control,您可以在任务栏上获得一个图标,当构建中断时,该图标会变为红色(甚至会与您交谈!)。
You should then do a nightly full clean build where the source version is labeled (given a unique build number) that you can choose to publish to your stakeholders (product managers, QA people). This is so that when a bug is reported, it is against a known build number (that's extremely important).
然后,您应该进行每晚全面清理构建,其中标记了源版本(给定唯一的内部版本号),您可以选择将其发布给您的利益相关者(产品经理,QA人员)。这是因为当报告错误时,它是针对已知的构建号(这是非常重要的)。
Ideally you should have an internal site where builds can be downloaded, and have a button you can click to publish the previous nightly build.
理想情况下,您应该有一个内部站点,可以下载构建,并有一个按钮,您可以单击以发布以前的每晚构建。
#6
Just trying to build a bit on what mjmarsh said, since he laid a great foundation...
试着建立一下mjmarsh说的话,因为他奠定了坚实的基础......
- Visual Studio. MSBuild works fine.
- NAnt.
- NantContrib. This will provide additional tasks such as Perforce operations.
- CruiseControl.net. This is again basically your "build dashboard".
视觉工作室。 MSBuild工作正常。
NantContrib。这将提供其他任务,例如Perforce操作。
CruiseControl.net。这基本上就是你的“构建仪表板”。
All of the above (save for VS) is open source, so you're not looking at any additional licensing.
以上所有(除VS之外)都是开源的,因此您不会考虑任何其他许可。
As Earwicker mentioned, build early, build often. Knowing something broke, and you can produce a deliverable is useful for catching stuff early on.
正如Earwicker所说,早建,经常建造。知道某些事情已经破裂了,你可以制作一个可交付成果对于早期捕捉东西很有用。
NAnt includes tasks for nunit/nunit2 as well, so you can actually automate your unit testing. You can then apply stylesheets to the results, and with the help of the framework provided by CruiseControl.net, have nice readable, printable unit test results for every build.
NAnt还包括nunit / nunit2的任务,因此您可以实际自动化单元测试。然后,您可以将样式表应用于结果,并在CruiseControl.net提供的框架的帮助下,为每个构建提供可读的,可打印的单元测试结果。
The same applies to the ndoc task. Have your documentation produced and available, for every build.
这同样适用于ndoc任务。为每个构建生成并提供您的文档。
You can even use the exec task to execute other commands, for instance, producing a Windows Installer using InstallShield.
您甚至可以使用exec任务执行其他命令,例如,使用InstallShield生成Windows Installer。
The idea is to automate the build as much as possible, because human beings make mistakes. Time spent up front is time saved down the road. People aren't having to babysit the build by going through the build process. Identify all the steps of your build, create NAnt scripts for each task, and build your NAnt scripts one by one until you've wholly automated your entire build process. It also then puts all of your builds in one place, which is good for comparison purposes. Something break in Build 426 that worked fine in Build 380? Well, there are the deliverables ready for testing -- grab them and test away.
我们的想法是尽可能地自动化构建,因为人类会犯错误。预先花费的时间是在路上节省的时间。人们不必通过构建过程来照看构建。确定构建的所有步骤,为每个任务创建NAnt脚本,并逐个构建您的NAnt脚本,直到您完全自动化整个构建过程。然后它还将所有构建放在一个位置,这有利于比较。 Build 426中的一些东西在Build 380中运行良好吗?好吧,有可交付的产品可供测试 - 抓住它们并进行测试。
#7
- No licenses needed. CruiseControl.net is freely available and only needs the .NET sdk to build.
- A build server, even without automated unit tests still provides a controlled environment for building releases. No more "John usually builds on his machine but he's out sick. For some reason I can't build on my machine"
- Right now I have one set up in a Virtual PC session.
- Yes. The build needs to be dumped somewhere accessible. Development builds should have debugging turned on. Release build should have it turned off.
- How often is up to you. If set up correctly, you can build after each check in will very little overhead. This is a great idea if you have (or are planning on having) unit tests in place.
- Keep milestones and releases as long as required. Anything else depends on how often you build: continuously? throw away. Daily? Keep a week's worth. Weekly? Keep two month's worth.
无需许可证。 CruiseControl.net是免费提供的,只需要构建.NET sdk。
构建服务器即使没有自动化单元测试,仍然可以为构建版本提供受控环境。没有更多“约翰通常建立在他的机器上,但他生病了。出于某种原因,我不能在我的机器上建造”
现在我在Virtual PC会话中设置了一个。
是。构建需要转储到可访问的地方。开发版本应该打开调试。发布版本应该关闭它。
多久由你自己决定。如果设置正确,您可以在每次检入后构建很少的开销。如果您已经(或正在计划进行)单元测试,这是一个好主意。
只要需要,就可以保留里程碑和版本。还有什么取决于你建立的频率:持续不断?丢弃。日常?保持一周的价值。每周?保持两个月的价值。
The larger your project gets the more you will see the benefits of an automated build machine.
项目越大,您就越能看到自动构建机器的好处。
#8
It is all about the health of the build. What this gets you is that you can set up any type of things you want to happen with the builds. Among these you can run tests, static analysis, and profiler. Problems are dealt with much much faster, when you recently worked on that part of the application. If you commit small changes, then it almost tells you where you broke it :)
这完全取决于构建的健康状况。这会让你获得的是你可以设置你想要在构建中发生的任何类型的事情。在这些中,您可以运行测试,静态分析和分析器。当您最近处理应用程序的这一部分时,问题的处理速度要快得多。如果您进行小的更改,那么它几乎会告诉您在哪里打破它:)
This of course assumes, you set it up to build with every check in (continuous integration).
当然,假设您将其设置为每次检入时都进行构建(持续集成)。
It also can help get QA and Dev closer. As you can set up functional tests to run with it, along with profiler and anything else that improves feedback to the dev team. This doesn't mean the functional tests run with every check in (can take a while), but you set up builds/tests with tools that are common to the whole team. I have been automating smoke tests, so in my case we collaborate even more closely.
它还可以帮助QA和Dev更接近。您可以设置功能测试以与其一起运行,以及分析器和其他任何可以改善开发团队反馈的内容。这并不意味着每次签入都会运行功能测试(可能需要一段时间),但是您可以使用整个团队通用的工具来设置构建/测试。我一直在自动化烟雾测试,所以在我的情况下,我们更紧密地合作。
#9
Why: 10 years ago we as software developers used to analyse something to the nth degree get the documents (written in a human language) 'signed off' then start writing code. We would unit test, string test and then we would hit system test: the first time the system as a whole would be run together, sometimes week or months after we got the documents signed off. It was only then that we would uncover all the assumptions and misunderstandings we had when we analysed everything.
为什么:10年前我们作为软件开发人员用来分析某些东西到第n级获取文档(用人类语言编写)'签名'然后开始编写代码。我们将进行单元测试,字符串测试,然后我们将进行系统测试:第一次整个系统将一起运行,有时是在我们签署文件后的一周或几个月。只有到那时我们才会发现我们分析所有内容时所有的假设和误解。
Continuous Integration as and idea causes you to build a complete (although, initially, very simple) system end to end. Over time the system functionality is built out orthogonally. Every time you do a complete build you are doing the system test early and often. This means you find and fix bugs and assumptions as early as possible, when it is the cheapest time to fix them.
持续集成和想法使您构建一个完整的(尽管最初非常简单)系统端到端。随着时间的推移,系统功能正交建立。每次完成构建时,您都会尽早并经常进行系统测试。这意味着您可以尽早找到并修复错误和假设,这是修复它们的最便宜的时间。
How: As for the how, I blogged about this a little while ago:[ Click Here]
方法:至于如何,我不久前在博客上发表了这篇文章:[点击这里]
Over 8 posts it goes step by step on how to set up a Jenkins server in a windows environment for .NET solutions.
超过8个帖子逐步介绍了如何在Windows环境中为.NET解决方案设置Jenkins服务器。