增量构建是否可以与持续集成相结合?
我们将 TeamCity 与 subversion 和 MSBuild 结合使用,并且我们遇到了由 Subversion 提交触发的持续构建问题。
连续构建被设置为进行增量构建(夜间构建是完整且干净的)。
如果开发人员在构建开始后(提交触发)但在构建使用该文件的对象之前第二次更改并提交文件,则会出现此问题。现在,对象文件获得的时间戳位于第二次提交的时间戳之后。这将导致所有后续增量构建跳过对文件的更改。
为了更加清晰起见,这里是时间线:
T1:开发人员提交 file.cpp(file.cpp 的时间为 T1)
T2:第一次增量构建在构建服务器上开始
T3:构建服务器获取最新更改的文件(T1 处的 file.cpp)
T4:开发者第二次提交file.cpp(file.cpp有T4)
T5:Buildserver将T1的file.cpp编译成file.obj(现在file.obj有时间T5)
T6:第一次构建完成(结果良好)
T7:第二次增量构建在构建服务器上启动
T8:构建服务器获取最新更改的文件(T4 处的 file.cpp)
现在的问题:
T9:构建服务器不会将(T4 的)file.cpp 编译为 file.obj,因为file.obj 属于 T5,因此编译器认为它比源文件新。
通过完整构建可以轻松解决该问题,但需要很长时间(如果没有单元测试则需要 30 分钟)。
增量构建是否可以与持续集成相结合?
编辑:此问题似乎仅在使用服务器端结账模式时发生。使用构建代理端签出模式,更改的文件将获取检索时间的时间戳,而使用服务器端签出,它们将获取提交时间作为时间戳。
We use TeamCity with subversion and MSBuild and we have a problem with the continuous build that is triggered by Subversion commits.
The continuous build is set-up to do incremental builds (the nightly build is full and clean).
The problem occurs if a developer changes and commits file for the second time after the build has started (commit triggered) but before the object that uses the file is built. Now the object file gets a timestamp that is after the timestamp of the second commit. This will cause all later incremental builds to skip the changes to the file.
For extra clarity here is the time line:
T1: Developer commits file.cpp (file.cpp has time T1)
T2: First incremental build starts on the build server
T3: Build server gets the files for the latest change (file.cpp at T1)
T4: Developer commits file.cpp for the second time (file.cpp has T4)
T5: Buildserver compiles file.cpp of T1 into file.obj (now file.obj has time T5)
T6: First Build finishes (result is good)
T7: Second incremental build starts on the build server
T8: Build server gets the files for the latest change (file.cpp at T4)
And now the problem:
T9: Build server doesn't compile file.cpp (of T4) into file.obj because file.obj is of T5 hence the compiler thinks it is newer than the source file.
The problem is easily fixed with a full build but those take a long time (30 minutes without unit tests).
Is incremental building possible in combination with Continuous Integration?
Edit: This problem only seems to happen when using server side checkout mode. With build agent side checkout mode changed files get the timestamp of the time of retrieval while with server side checkout they get the commit time as timestamp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你肯定有竞争条件。我想你可以尝试通过询问更改日志并触摸其中列出的任何文件来变得聪明 - 或者更好的是,如果支持 Subversion 不保留文件修改时间,而是让文件的日期戳是它们的日期已更新位于。
我在这方面看到的一个错误是大部分时间只运行增量构建,但有一部分构建运行干净(可能每晚)。您可能会定期陷入这种竞争状况,但您会定期摆脱这种状况。根据这种情况发生的频率,这种拼凑可能就足够了。
Yes, you definitely have a race condition. I suppose you could try to get clever by interrogating the change log, and touching any files listed in there - or better yet, if it's supported have Subversion not preserve file modification times, rather have the date stamp of the files be the date they were updated located.
One of the kludges I've seen around this is to only run incremental builds most of the time, but have some fraction of the builds run a clean (perhaps nightly). You might get caught in this race condition periodically, but you'll break out of it on a regular basis. Depending on how frequently this occurs, this kludge may be good enough.