Skip to content

Instantly share code, notes, and snippets.

@antonarhipov
Created January 10, 2020 12:33
Show Gist options
  • Save antonarhipov/684ee96d1430a38403e8765e63af61b0 to your computer and use it in GitHub Desktop.
Save antonarhipov/684ee96d1430a38403e8765e63af61b0 to your computer and use it in GitHub Desktop.
TeamCity Kotlin DSL - using type inheritance for settings reuse in build configurations
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot
version = "2019.2"
project {
vcsRoot(ProjectVcs)
buildType(BuildA)
buildType(BuildB)
}
object ProjectVcs : GitVcsRoot({
name = "ProjectVcs"
url = "git://some.git.repository"
})
//---------------------------------------------------------------------------
open class MyCommonTemplate : BuildType({
steps {
script {
scriptContent = """echo "Hello from base template" """
}
}
})
object BuildA : MyCommonTemplate() {
init {
name = "BuildA"
steps {
script {
scriptContent = """echo "More steps for A" """
}
}
}
}
object BuildB : MyCommonTemplate() {
init {
name = "BuildB"
steps {
script {
scriptContent = """echo "More steps for B" """
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment