在 TeamCity 中使用全局属性或构建步骤
我的 TeamCity 服务器中有很多项目,用于构建和测试多个站点。我们每天晚上都使用 Selenium RC 来测试站点,我想重复使用一个步骤或配置,而不是在每个项目中都有副本。
我已经研究过使用模板,但它们似乎只能从定义它的项目中访问。属性也是如此,因为我尝试将路径和一些共享值放入系统或环境属性中,并使用复制的构建步骤共享属性。
但这一切都失败了,因为这些方法似乎都无法跨项目使用。您如何解决此类问题?无论如何,这一定是可能的,对吧?
I have a lot of projects in my TeamCity server, for building and testing multiple sites. We use Selenium RC to test the sites every night, and I would like to reuse one step or configuration instead of having copies in each project.
I have looked into using Templates, but they only seem to be accessible from the project it is defined in. The same goes for properties, as I tried to put paths and some shared values in system or environment properties and using copied build steps using those shared properties.
But it all fails, as none of these methods seem to be usable across projects. How do you solve this type of issue? It must be possible somehow, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据我对您的问题的评论,您可以在多个项目中使用单个模板配置构建。
有关如何执行此操作的信息,请参阅 TeamCity 文档。
As per my comments for your question you can use a single template configuration build across multiple Projects.
See TeamCity documention for information on how to do this.
TeamCity 有一项新功能(自 8.0 起)支持全局配置/参数/环境变量。 8.0 支持项目组织/嵌套的新概念,并且作为该功能集的一部分,所有项目现在都继承自“Root”项目。在该根项目上,您可以指定许多内容,包括参数等。这似乎不支持构建步骤。
他们在 http://youtrack.jetbrains.com/issue/TW-11202。
--
TeamCity has a new feature (as of 8.0) that supports global configs/parameters/env variables. 8.0 supports the new concept of project organization/nesting, and as part of that feature set all projects now inhert from the "Root" project. And on that root project you can specify a number of things, including parameters, etc. This does not appear to support build steps.
They documented the change in http://youtrack.jetbrains.com/issue/TW-11202.
--
您可以通过创建一个具有共享属性的虚拟构建配置来实现“全局属性”,然后对于需要访问全局属性的所有构建,您可以创建构建依赖项。当调用真正的构建配置时,它将首先调用依赖的构建配置(这没有任何意义),然后传递依赖配置的属性(带有 dep.bt 前缀,而不仅仅是系统前缀)。
根据共享构建步骤中所需的逻辑,您也许能够在依赖构建中实际执行实际逻辑(它将无法从“真实”构建继承任何属性或 VCS 详细信息)。
You could achieve a "global property" by creating a dummy build configuration which has your shared properties then for all your builds which need access to the global properties you create a build dependency. When your real build configuration is called it will first call the dependent build configuration (which does nothing meaningful) then it passes the properties from the dependent config (with a dep.bt prefix instead of just the system prefix).
Depending on the logic you need in a shared build step you may be able to actually perform real logic in the dependent build (it won't be able to inherit any properties or VCS details from the "real" build).
由于这有点过时,并且上面的答案并不完全清楚,所以我想发布我如何使用 TeamCity 8+ 做到这一点。
基本上,模板可以在项目及其子项目中使用。如果将模板移至父项目,则原始项目的所有同级项目都可以使用该模板。
注意:如果模板附加到绑定到当前项目的 VCS 根,您首先必须将 VCS 根移动到您尝试将模板移动到的同一级别。
Since this is a bit outdated, and the answers above aren't completely clear, thought I would post how I did this with TeamCity 8+.
Basically, a template can be used within the project and its children. If you move a template to the parent, it becomes available to all the siblings of the original project.
Note: If the template is attached to a VCS root that is bound to the current project, you'll first have to move the VCS root to the same level to which you're trying to move the template.