我正在尝试设置一个TeamCity元运行器,它为许多参数提供默认值。一些参数通过包含它们而彼此依赖。这是一个(人为的)例子:
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="TestMetaRunner">
<description>Test the MetaRunners</description>
<settings>
<parameters>
<param name="testMetaRunner.Name" value="theName" />
<param name="testMetaRunner.Value" value="theValue" />
<param name="testMetaRunner.Arguments" value="-param %testMetaRunner.Name%=%testMetaRunner.Value%" />
</parameters>
<build-runners>
<runner name="Do it" type="simpleRunner">
<parameters>
<param name="script.content" value="someCommand %testMetaRunner.Arguments%" />
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
</build-runners>
<requirements />
</settings>
</meta-runner>
通常,元运行程序的用户只会指定参数testMetaRunner.Name
和testMetaRunner.Value
,但对于更复杂的用法,testMetaRunner.Arguments
需要直接修改。
问题是,TeamCity似乎无法解析参数值中的参数,因此传递给script.content
的值仍然包含参数名称 - 显然不是我想要达到的目的。
使用meta runners实现上述方案的正确方法是什么?
答案 0 :(得分:0)
一种可能的解决方案是为每个抽象级别创建专用元运行器,并在更具体的元运行器中重用元运行器作为另一个构建步骤。< / p>
应用于上面的示例,这会产生以下两个元运行规范:
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="TestMetaRunnerGeneric">
<description>Test the MetaRunners</description>
<settings>
<parameters>
<param name="testMetaRunner.Arguments" spec="text validationMode='not_empty'" />
</parameters>
<build-runners>
<runner name="Do it" type="simpleRunner">
<parameters>
<param name="script.content" value="someCommand %testMetaRunner.Arguments%" />
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
</build-runners>
<requirements />
</settings>
</meta-runner>
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="TestMetaRunnerSpecific">
<description>Test the MetaRunners</description>
<settings>
<parameters>
<param name="testMetaRunner.Name" value="theName" />
<param name="testMetaRunner.Value" value="theValue" />
</parameters>
<build-runners>
<runner name="Call other meta runner" type="TestMetaRunnerGeneric">
<parameters>
<param name="testMetaRunner.Arguments" value="-param %testMetaRunner.Name%=%testMetaRunner.Value%" />
</parameters>
</runner>
</build-runners>
<requirements />
</settings>
</meta-runner>