我已将我的 Teamcity 构建提取为 Kotlin 输出。我想创建一个定义许多常见步骤/设置的基类,但允许单个构建扩展这些属性。
例如
open class BuildBase(init: BuildBase.() -> Unit) : BuildType({
steps {
powerShell {
name = "Write First Message"
id = "RUNNER_FirstMessage"
scriptMode = script {
content = """
Write-Host "First Message"
""".trimIndent()
}
}
}
})
object Mybuild : BuildBase({
steps { // This would add a new step to the list, without wiping out the original step
powerShell {
name = "Write Last Message"
id = "RUNNER_LastMessage"
scriptMode = script {
content = """
Write-Host "Last Message"
""".trimIndent()
}
}
}
})
在此示例中,我想从基类继承步骤,但添加与特定构建相关的其他步骤。此外,我想继承基础disableSettings
(如果有的话)并禁用其他步骤。
这甚至可能吗?如果是这样,我将如何构建类以启用它?