什么是TeamCity Kotlin DSL中的Meta Runner的替代品?

很明显,TeamCity Kotlin DSL中不会支持metarunners的生成。 这些文件保持纯XML格式。

如何使用可用的DSLfunction替换它? 说我想这样做:

steps { step { type = "mymetarunner" // compound meta-runner step } } 

如何使用Kotlin定义mymetarunner

目前(TeamCity 2017.2),没有办法使用Kotlin DSL定义metarunners。

更新如果不需要真正的metarunner,解决方案是Kotlin DSL的一个小练习

定义“metarunner”需要的设置的容器类

 class MyConfigClass { var name = "Default Name" var goals = "build" var tasks = "build test" var someUnusedProperty = 0 } 

定义steps块的扩展function

 fun BuildSteps.myMetaRunner(config: MyConfigClass.() -> Unit) { val actualConfig = MyConfigClass() // new config instance actualConfig.config() // apply closure to fill the config // use the config to create actual steps maven { name = actualConfig.name goals = actualConfig.goals } ant { name = actualConfig.tasks } } 

使用扩展function,无论你需要

 object A_Build : BuildType({ uuid = ... steps { myMetaRunner { name = "This name will be used by maven step" goals = "build whatever_goal" tasks = "more ant tasks" } } }) 

答对了!