简体   繁体   English

TeamCity:项目参数继承问题?

[英]TeamCity : project parameters inheritance issue?

I have a TeamCity 8.0.3 project with multiple configs inside which have a common parameter (defined as a project parameter) : targetServerIP .我有一个 TeamCity 8.0.3 项目,其中包含多个配置,其中有一个公共参数(定义为项目参数): targetServerIP One of these configs is a " 1 click deployment " which starts others configs by using snapshots dependencies.这些配置之一是“一键部署”,它通过使用快照依赖项启动其他配置。 I've set the parameter as "prompt" so the IP is asked on each run of any configs, this is what我已将参数设置为“提示”,因此每次运行任何配置时都会询问 IP,这就是

Problem : Individually it works fine, on each config run the IP is asked and successfully applied to the config.问题:单独工作正常,在每次配置运行时都会询问 IP 并成功应用于配置。 But when I execute the " 1 clic deployment " it also asks the IP but does not transmit it to other dependants configs (the value stays <empty> ).但是,当我执行“ 1 clic deployment ”时,它也会询问 IP,但不会将其传输到其他相关配置(值保持为<empty> )。

My question : How can I set this parameter to be applyed to others configs when it is prompted ?我的问题:当出现提示时,如何将此参数设置为应用于其他配置?

PS : I've obviously tried to set it as an env. PS:我显然试图将其设置为环境env. parameter but it does not helps.参数,但它没有帮助。

PS2 : Using templates does not seems to be a good solution for me. PS2:使用模板对我来说似乎不是一个好的解决方案。

There are 2 problems.有2个问题。 One I can help with, one I am trying to solve myself just solved myself.一个我可以帮助, 一个我试图解决自己的问题 只是解决了自己。

Your problem is how you setup the chain.你的问题是你如何设置链条。 The 1 click deployment "depends" on the others. 1 单击部署“取决于”其他部署

It cannot pass parameters to the other builds.不能将参数传递给其他构建。
It can use parameters from the dependent builds by dep.dependent_build_configuration.paramter_name .可以通过dep.dependent_build_configuration.paramter_name使用依赖构建中的参数

The fix修复

There are 2 things you have to do.你必须做两件事。

  1. Setup artifact dependencies设置工件依赖项
  2. Setup triggers设置触发器

Build A建个

- Parameters - 参数

GlobalParameter全局参数

  • Display : Normal显示:正常
  • Type : Text类型:文本
  • Allowed Value : Not Empty允许值:不为空

Build B建造 B

- Parameters - 参数

LocalParameter本地参数

  • Display : hidden显示:隐藏
  • Type : Text类型:文本
  • Value %dep.Build_A_GlobalParemeter%%dep.Build_A_GlobalParemeter%

- Snapshot Dependency - 快照依赖

  • Depends on : "Build A"取决于:“构建 A”

- Triggers - 触发器

  • TriggerType : Finish Build Trigger TriggerType : 完成构建触发器
  • Build Configuration : Build A构建配置:构建 A

How this works这是如何工作的

The artifact dependency makes the variables available via the %dep.Build_A.GlobalParameter% syntax.工件依赖项通过%dep.Build_A.GlobalParameter%语法使变量可用。 The Finish Build Trigger causes Build A to trigger Build B . Finish Build Trigger导致Build A触发Build B You will have access to the parameters because they are saved from the previous build.您将可以访问参数,因为它们是从以前的构建中保存的。

Until today (1 month) I've not found where the problem is (many days lost in investigation), the only workaround is to manually change value of parameter each time I need to.直到今天(1 个月)我还没有找到问题所在(在调查中丢失了很多天),唯一的解决方法是每次需要时手动更改参数的值。

Maybe there is something special to do with the XML config files ?也许 XML 配置文件有什么特别之处? I don't know.我不知道。

In completion to @Brandon's response, you may achieve what you wanted to do in the first place using the TeamCity RestAPI you may call resulting properties on a build ID to see what properties were set on the build.在完成@Brandon 的响应后,您可以首先使用 TeamCity RestAPI 实现您想要做的事情,您可以在构建 ID 上调用结果属性,以查看在构建中设置了哪些属性。

curl my.teamcityserver.com/app/rest/builds/<some-parent-build-id>/resulting-properties

search the parameter name you need in the XML and you should be able to get the value from the parent build.在 XML 中搜索您需要的参数名称,您应该能够从父构建中获取值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM