jetbrains.buildServer.configs.kotlin.v2017_2

Package jetbrains.buildServer.configs.kotlin.v2017_2

Defines the settings DSL for TeamCity 2017.2+

Most of the classes in the DSL correspond to the entities in TeamCity administration UI. The main classes are:

Compared with the DSL API v10, this version provides an ability to edit settings in the UI, better settings validation, and improved completion in IDE.

Migrating from DSL API v10

If you didn't refactor the code generated using the DSL API v10, then the easiest way to migrate to v2017_2 is to disable versioned settings and then re-enable them. In this case, TeamCity will remove the old settings from your repository and commit current settings instead.

If you changed the code generated by TeamCity, then an automatic migration is not possible and you have to migrate manually by changing the packages in your imports from jetbrains.buildServer.configs.kotlin.v10 to jetbrains.buildServer.configs.kotlin.v2017_2. Most of the API is the same between these packages and should not require any modifications.

To provide better completion in the IDE, many classes in the DSL API v2017_2 are marked with the @TeamCityDsl annotation which makes some members and properties from the outer scope inaccessible. This can cause compilation errors after migrating to v2017_2. For example, the following build step printing buildType's description won't compile:

BuildType({
    ...
    description = "Build Description"
    ....
    steps {
        script {
            scriptContent = """
                #!/bin/bash
                echo '$description'
            """.trimIndent()
        }
    }
})

You can still access outer scope members using labels:

BuildType(buildType@{
    ...
    description = "Build Description"
    ....
    steps {
        script {
            scriptContent = """
                #!/bin/bash
                echo '${this@buildType.description}'
            """.trimIndent()
        }
    }
})

Another difference between the API versions is how parts of the settings are registered. In v10 it is possible to register several buildTypes like this:

Project({
    ...
    val build = BuildType() //fill build settings
    for (OS in arrayOf("Linux", "Mac", "Windows")) {
        build.uuid += "_$OS"
        build.extId += "_$OS"
        build.name = "Tests: $OS"
        buildType(build)
    }
})

A call to buildType() copies the specified buildType, so subsequent modifications don't affect the copy. In the DSL API v2017_2 buildType is not copied, so the code above registers 3 builds with same settings. You can either fill all settings inside the loop or use the copy() extension function:

Project({
    ...
    val build = BuildType() //fill build settings
    for (OS in arrayOf("Linux", "Mac", "Windows")) {
        buildType(build.copy().apply {
            uuid += "_$OS"
            id += "_$OS"
            name = "Tests: $OS"
        })
    }
})

The same applies to VCS roots, templates, subprojects as well as build settings parts like build steps or triggers.

Types

ArtifactDependency

class ArtifactDependency

TeamCity artifact dependency.

BuildFeature

open class BuildFeature : Parametrized, Validatable

Represents TeamCity build feature

BuildFeatures

class BuildFeatures : Validatable

Collection of build features in build configuration or template

BuildRule

data class BuildRule

A rule matching a build, use one of the methods in ArtifactDependency class to create it

BuildStep

open class BuildStep : Parametrized, Validatable

Represents TeamCity Build Step

BuildSteps

class BuildSteps : Validatable

Collection of build steps in build configuration or template

BuildType

open class BuildType : BuildTypeSettings, Validatable

Represents TeamCity build configuration.

BuildTypeSettings

open class BuildTypeSettings : Validatable

Contains common settings between BuildType and Template

CheckoutMode

enum class CheckoutMode

VCS checkout mode, specifies how sources are transferred to the build agent

Cleanup

class Cleanup

Specifies clean-up rules for project, build configuration, or template

CleanupLevel

enum class CleanupLevel

Specifies what data should be cleaned. Each level includes the one(s) above it.

CleanupRule

data class CleanupRule

Clean-up rule, use one of the methods in Cleanup to create it

CompoundDelegateProvider

class CompoundDelegateProvider<T : CompoundParam<T>>

CompoundParam

abstract class CompoundParam<V> : Parametrized

CompoundParamDelegate

class CompoundParamDelegate<T : CompoundParam<T>> : ParameterDelegate<T>

Consumer

class Consumer : ErrorConsumer

Dependencies

class Dependencies

Collection of dependencies in build configuration or template

Dependency

class Dependency

Represents dependency of one build on another

ErrorConsumer

interface ErrorConsumer

Consumes validation errors

FailureAction

enum class FailureAction

Action in case of snapshot dependency failure.

FailureCondition

open class FailureCondition : BuildFeature

TeamCity failure condition

FailureConditions

class FailureConditions : Validatable

Collection of failure conditions in build configuration or template

IdGenerator

class IdGenerator

IdeaDuplicates

class IdeaDuplicates : IdeaSettingsBasedRunner

IdeaInspections

class IdeaInspections : IdeaSettingsBasedRunner

IdeaRunner

class IdeaRunner : IdeaSettingsBasedRunner

IdeaSettingsBasedRunner

abstract class IdeaSettingsBasedRunner : BuildStep

Options

class Options : Parametrized

Parameter

data class Parameter

Build parameter

ParameterDelegate

abstract class ParameterDelegate<T>

ParameterDisplay

enum class ParameterDisplay

Specifies how parameter is shown in the Run Custom Build dialog

ParameterSpec

sealed class ParameterSpec

Parameter specification

ParameterSpecCheckbox

class ParameterSpecCheckbox : ParameterSpec

ParameterSpecFreeForm

class ParameterSpecFreeForm : ParameterSpec

ParameterSpecPassword

class ParameterSpecPassword : ParameterSpec

ParameterSpecRegex

class ParameterSpecRegex : ParameterSpec

ParameterSpecSelect

class ParameterSpecSelect : ParameterSpec

ParameterSpecText

class ParameterSpecText : ParameterSpec

Parametrized

open class Parametrized

ParametrizedWithType

open class ParametrizedWithType : Parametrized

Allows to add parameters to project, build configuration, or template

Project

open class Project : Validatable

Represents TeamCity project.

ProjectFeature

open class ProjectFeature : Parametrized, Validatable

Represents project-level feature

ProjectFeatures

class ProjectFeatures : Validatable

Collection of features in a project

PublishMode

enum class PublishMode

This class is used to describe condition for artifact publishing at the end of the build

Requirement

data class Requirement

An agent requirement, use methods in Requirements class to create it

RequirementType

enum class RequirementType

Requirements

class Requirements

Collection of agent requirements in build configuration or template

ReuseBuilds

enum class ReuseBuilds

Reuse builds mode for snapshot dependencies

SingleDelegateProvider

class SingleDelegateProvider<T>

SingleParamDelegate

class SingleParamDelegate<T> : ParameterDelegate<T>

SnapshotDependency

class SnapshotDependency

TeamCity snapshot dependency

Template

open class Template : BuildTypeSettings, Validatable

Represents TeamCity build template.

Trigger

open class Trigger : Parametrized, Validatable

TeamCity build trigger

Triggers

class Triggers : Validatable

Collection of build triggers in build configuration or template

Validatable

interface Validatable

VcsRoot

open class VcsRoot : Parametrized, Validatable

A base class representing TeamCity VCS root.

VcsSettings

class VcsSettings

Contains settings from the Version Control Settings tab of build configuration or template.

_Samples

class _Samples

Annotations

TeamCityDsl

annotation class TeamCityDsl

Extensions for External Classes

kotlin.String

Properties

TQ

val TQ: String

Used to escape triple quotes inside multi-line strings

version

var version: String?

Version of TeamCity in which kotlin code was generated.

Functions

copy

fun <T : VcsRoot> T.copy(): T

Copies the receiver VCS root.

fun <T : VcsRoot> T.copy(block: T.() -> Unit): T

Copies the receiver VCS root and initialize it with the specified block.

fun ArtifactDependency.copy(): ArtifactDependency

Copies the receiver artifact dependency

fun SnapshotDependency.copy(): SnapshotDependency

Copies the receiver snapshot dependency

fun Dependency.copy(): Dependency

Copies the receiver dependency

fun BuildSteps.copy(): BuildSteps

Copies the receiver build steps

fun Cleanup.copy(): Cleanup

Copies the receiver cleanup

fun FailureConditions.copy(): FailureConditions

Copies the receiver failure conditions

fun VcsSettings.copy(): VcsSettings

Copies the receiver vcs settings

fun Triggers.copy(): Triggers

Copies the receiver triggers

fun Requirements.copy(): Requirements

Copies the receiver requirements

fun Dependencies.copy(): Dependencies

Copies the receiver dependencies

fun BuildFeatures.copy(): BuildFeatures

Copies the receiver build features

fun ProjectFeatures.copy(): ProjectFeatures

Copies the receiver project features

copySettingsTo

fun <T : BuildTypeSettings> T.copySettingsTo(target: T): T

Copies the receiver build settings to the specified target

copyTo

fun <T : VcsRoot> T.copyTo(target: T): T

Copies the receiver VCS root to the specified target VCS root

fun BuildSteps.copyTo(target: BuildSteps): BuildSteps

Copies the receiver build steps to the specified target

fun Cleanup.copyTo(target: Cleanup): Cleanup

Copies the receiver cleanup to the specified target

fun FailureConditions.copyTo(target: FailureConditions): FailureConditions

Copies the receiver failure conditions to the specified target

fun VcsSettings.copyTo(target: VcsSettings): VcsSettings

Copies the receiver vcs settings to the specified target

fun Triggers.copyTo(target: Triggers): Triggers

Copies the receiver triggers to the specified target

fun Requirements.copyTo(target: Requirements): Requirements

Copies the receiver requirements to the specified target

fun Dependencies.copyTo(target: Dependencies): Dependencies

Copies the receiver dependencies to the specified target

fun BuildFeatures.copyTo(target: BuildFeatures): BuildFeatures

Copies the receiver build features to the specified target

fun ProjectFeatures.copyTo(target: ProjectFeatures): ProjectFeatures

Copies the receiver project features to the specified target

ideaDuplicates

fun BuildSteps.ideaDuplicates(init: IdeaDuplicates.() -> Unit = {}): Unit

ideaInspections

fun BuildSteps.ideaInspections(init: IdeaInspections.() -> Unit = {}): Unit

ideaRunner

fun BuildSteps.ideaRunner(init: IdeaRunner.() -> Unit = {}): Unit

project

fun project(project: Project): Unit
fun project(init: Project.() -> Unit): Unit

Defines TeamCity project

runPrivileged

fun <T> runPrivileged(function: () -> T): T