Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Teamcity Kotlin构建基类属性扩展_Kotlin_Teamcity_Kotlin Dsl - Fatal编程技术网

Teamcity Kotlin构建基类属性扩展

Teamcity Kotlin构建基类属性扩展,kotlin,teamcity,kotlin-dsl,Kotlin,Teamcity,Kotlin Dsl,我已将我的Teamcity构建提取为Kotlin输出。我想创建一个基类,它定义了许多常见的步骤/设置,但允许单个构建扩展这些属性 e、 g 在本例中,我希望从基类继承步骤,但添加与特定构建相关的其他步骤。此外,我希望继承基本禁用设置(如果有)并禁用其他步骤 这可能吗?如果是这样的话,我将如何构建类以启用它?您可能已经找到了解决方案,但下面是我将如何解决您的问题 与GUI中一样,TeamCity支持构建模板。 在您的情况下,您将拥有如下模板: object MyBuildTemplate: Tem

我已将我的Teamcity构建提取为Kotlin输出。我想创建一个基类,它定义了许多常见的步骤/设置,但允许单个构建扩展这些属性

e、 g

在本例中,我希望从基类继承步骤,但添加与特定构建相关的其他步骤。此外,我希望继承基本
禁用设置(如果有)并禁用其他步骤


这可能吗?如果是这样的话,我将如何构建类以启用它?

您可能已经找到了解决方案,但下面是我将如何解决您的问题

与GUI中一样,TeamCity支持构建模板。 在您的情况下,您将拥有如下模板:

object MyBuildTemplate: Template({
  id("MyBuildTemplate")
  name = "My build template"

  steps {
    powerShell {
        name = "Write First Message"
        id = "RUNNER_FirstMessage"
        scriptMode = script {
            content = """
                Write-Host "First Message"
            """.trimIndent()
        }
    }
  }
})
然后,您可以定义扩展此模板的生成配置:

object MyBuildConfig: BuildType({
  id("MyBuildConfig")
  name = "My build config"

  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()
        }
    }

    // afaik TeamCity would append the build config's steps to the template's steps but there is way to explicitly define the order of the steps:
    stepsOrder = arrayListOf("RUNNER_FirstMessage", "RUNNER_LastMessage")
  }
})
这样,您还应该能够从模板继承
禁用设置

object MyBuildConfig: BuildType({
  id("MyBuildConfig")
  name = "My build config"

  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()
        }
    }

    // afaik TeamCity would append the build config's steps to the template's steps but there is way to explicitly define the order of the steps:
    stepsOrder = arrayListOf("RUNNER_FirstMessage", "RUNNER_LastMessage")
  }
})