通过TeamCity 9中的参数值覆盖依赖关系属性 [英] Override dependencies properties by parameters value in TeamCity 9

查看:434
本文介绍了通过TeamCity 9中的参数值覆盖依赖关系属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TeamCity 9中,我有两个构建配置:A,B依赖于A(快照依赖关系)。有时候A单独开始,有时与B连接。
我想将A的<。code> build.number 更改为(例如) 0。 < B的build.counter 当A触发A时。

In TeamCity 9 I have two build configurations: A, B which depends on A (snapshot dependency). Sometimes A starts alone, sometimes in chain with B. I want to change build.number of A to (for example) 0.<build.counter of B> when A triggered by B.

根据 docs


由于TeamCity 9.0,有可能通过在依赖构建中重新定义来重写
依赖关系参数。对于
示例,构建配置A取决于B和B取决于C; A有
可以使用
以下格式更改其任何依赖关系中的参数:

Since TeamCity 9.0, there is a possibility to override the dependencies parameters by redefining them in the dependent build. For example, build configuration A depends on B and B depends on C; A has the ability to change parameters in any of its dependencies using the following format:

reverse.dep。 < btID>。< property name>

好的,我在B中创建了配置参数: code> reverse.dep.A.build.number = 0%build.counter%
所以,当我启动构建链时,我认为A的build.number 将更改为 0.123 (例如, B的build.counter 等于123),而是将字符串 0.%build.counter%已传递给A并且A使用自己的属性 build.counter

Ok, I created configuration parameter in B: reverse.dep.A.build.number=0.%build.counter%. So, when I start the build chain I suppose build.number of A will changed to 0.123 (for example, build.counter of B equal to 123), but instead the string 0.%build.counter% has been passed to A and A uses own property build.counter.

如何精确传递TeamCity参数的值?

How to pass exactly values of TeamCity parameters?

推荐答案

考虑问题

没有办法通过 reverse.dep。语法。


reverse.dep参数值按照依次链接传递。

reverse.dep parameters values are passed down the dependency chain as is.

(从这里: https://youtrack.jetbrains.com/问题/ TW-40772

考虑问题


  1. 创建配置C

  2. 从A添加到C strong>如果有合适的选项,请不要运行新构建选项

  3. 从B添加到C快照依赖关系,而不使用相同的选项。 / li>
  4. 将参数从B传递到A到 reverse.dep.A.use_C_number = true ,所以A知道使用什么计数器。

  5. 在A中的脚本(新构建步骤)中使用此参数,例如(PowerShell):

  1. Create configuration "C"
  2. Add to "C" snapshot dependency from "A" with "Do not run new build if there is a suitable one" option
  3. Add to "C" snapshot dependency from "B" without same option.
  4. Pass parameter from "B" to "A" through reverse.dep.A.use_C_number=true, so "A" knows what counter to use.
  5. Use this parameter in script (new build step) in "A", for example (PowerShell):

# Gets build.number of "C"
$C_num = "%dep.C.build.number%"

# Gets 'use_C_number' parameter
$use_C_number = "%use_C_number%"

# Change current build.number if needed
if ($use_C_number -eq "true") {
  Host-Write "##teamcity[buildNumber '1.2.3.$C_num']"
}


在这种情况下,C将仅由B而不是A触发,因为A将始终使用适合的C( C没有附加VCS根)

注意:它应该是至少一个完成的C版本。

注意:在所有情况下,我不确定适合的构建,因为文档对于没有VCS根附件的情况并不清楚d建立配置,但它的工作。无论如何,在TeamCity跟踪器中有问题

In this case "C" will be triggered only by "B" and not by "A", because "A" will always use "suitable" build of "C" ("C" has no VCS root attached).
Note: it should be at least one finished build of "C".
Note: I'm not sure about "suitable" build in all cases, because documentation is not clear for situation with no VCS root attached to build configuration, but it works. In any case there is a question in TeamCity tracker.

所以,只有当B排队时,C的build.counter才会递增。
当A单独启动时,它使用默认的 build.number

So, C's build.counter will be incremented only when "B" is queued. When "A" started alone it use default build.number.

感谢Nikita Skvortsov为我的解决方案。

P.S. Thanks to Nikita Skvortsov for targetting me to the solution.

这篇关于通过TeamCity 9中的参数值覆盖依赖关系属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆