我已经提取了Kotlin输出的Teamcity版本。我想创建一个基类,该基类定义了许多常用的步骤/设置,但允许单独的构建来扩展这些属性。
例如
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
(如果有)并禁用其他步骤。
这甚至可能吗?如果是这样,我将如何构建类以启用它?