如何在 TeamCity 中正确处理共享项目
假设我在 TeamCity 中有两个“项目”,它们是两个网站,每个项目都使用不在网站 svn 路径内的共享库。下面是 svn 结构,以便更清楚地显示:
网站 A:svn://root/web/websitea(使用共享库 a)
网站 B:svn://root/web/websiteb(使用共享库 b)
共享库 A : svn://root/shared/liba
共享库 B: svn://root/shared/libb
如何为网站 a 设置 teamcity 项目?现在我让它指向 svn://root ,但这会使其触发构建,即使网站 b 或共享库 b 发生了更改,这是不对的。我真正需要的是一种仅在 svn://root/web/websitea 或 svn://root/shared/liba 发生更改时才触发构建的方法。
我尝试在同一个项目中设置两个 vcs 根目录,它们指向上面的两个 svn 路径,但是似乎没有办法为每个 vcs 根目录设置工作目录。因此,它最终只是将两个 svn 路径的内容直接复制到我的构建目录的根目录中,而不是将它们放在正确的位置(C:\Build\Web\WebsiteA 和 C:\Build\Shared\ LibA)。
Let's say I have two "projects" within TeamCity, which are two websites, that each use a shared library that isn't within the svn path of the website. Here is the svn structure to make it more clear:
Website A: svn://root/web/websitea (uses shared library a)
Website B: svn://root/web/websiteb (uses shared library b)
Shared Library A: svn://root/shared/liba
Shared Library B: svn://root/shared/libb
How would I setup a teamcity project for website a? Right now I have it point to the svn://root but that would make it trigger a build even if website b or shared library b was changed, which is not right. What I really need is a way for it to trigger a build only if there is a change in svn://root/web/websitea OR in svn://root/shared/liba.
I tried setting up two vcs roots within the same project which point to the two svn paths above, however there doesn't seem to be a way to set a working directory for each vcs root. For this reason, it ended up just copying the contents of the two svn paths directly into the root of my build directory instead of putting them in the proper places (C:\Build\Web\WebsiteA & C:\Build\Shared\LibA).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TeamCity 的结账规则功能能够支持您所描述的设置。我的团队用它来做类似于你想做的事情。
首先,设置一个 SVN Root。该根的 URL 将类似于以下内容:
然后设置以下结帐规则。
对于项目 A:
对于项目 B:
有关签出规则的 TeamCity 文档对此并不完全清楚,但只有您包含的特定路径才会用于触发构建。这应该满足您的需要,只需更改 websitea 和 liba 即可触发其构建(B 也相同)。
TeamCity's checkout rules functionality is able to support the setup you're describing. My team uses it to do something similar to what you're trying to do.
First, set up a single SVN Root. The URL of this root would be something like this:
Then set up the following checkout rules.
For Project A:
For Project B:
The TeamCity documentation on checkout rules isn't totally clear about this point, but only the particular paths you have included will be used to trigger builds. This should meet your need to have only changes is websitea and liba trigger its build (and the same for B).
除了 Eric 提到的之外,如果您需要签出整个源根目录,但仅根据特定路径触发构建,则可以在“构建触发”部分中编辑 VCS 触发器规则,使其具有如下内容:
In addition to what Eric mentioned, if you need the entire source root to be checked out, but only trigger the build based on particular paths, you can edit the VCS Trigger rules in the Build Triggering section to have something like: