Project

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

Represents TeamCity project.

The id and name are mandatory properties for a valid project (id can be omitted if it matches the class name).

The parentId property defines a place for this project in a project hierarchy, it should be empty for the Root project on the server, and non-empty for other projects.

To appear in UI project should be either registered via the project call in the settings.kts or added as a subproject to a registered project via the subProject() method.

BuildTypes, templates, and vcsRoots can be registered in the project using the buildType, template, and vcsRoot methods accordingly. BuildTypes and subprojects order can be specified via the buildTypesOrder and subProjectsOrder methods.

Project parameters are defined inside the params block.

The cleanup tab in the project admin UI contains clean-up rules for the project itself, its subprojects, and build configurations. In DSL the cleanup block in the project defines the clean-up rules for the project itself, subprojects and buildTypes can define their own clean-up rules or inherit them from the parent project(default).

Other tabs in the project admin UI are either not stored in VCS (e.g. SSH keys), or are defined as project features in the features block.

Example. Project with a single VCS root and a build configuration

object MyProject: Project({
name = "Main"
description = "The main branch"

vcsRoot(GitVcsRoot{
id("ProjectRepository")
name = "Project Repository"
url = "<git fetch URL>"
branch = "refs/heads/main"
})

buildType {
id("RunTests")
name = "Runs all tests"

vcs {
root(RelativeId("ProjectRepository"))
}

steps {
maven {
goals = "clean test"
}
}
}
})
























Example. Project with a few subprojects

object MyProject: Project({
name = "Main"
description = "The main project"

subProject {
id("AllTests")
name = "Subproject for different kinds of tests"

buildType(UnitTests)
buildType(IntegrationTests)
}

subProject {
id("Packages")
name = "Subproject for packages"

buildType(Executable)
buildType(Docker)
}
})


















See also

Constructors

Link copied to clipboard
constructor(init: Project.() -> Unit)

Creates a project and initializes it with the specified init block

constructor()

Properties

Link copied to clipboard

Whether this project is archived

Link copied to clipboard
Link copied to clipboard

Specifies buildTypes order. Contains buildType ids. Can be also be filled by buildTypesOrder property

Link copied to clipboard

Id of default template. Null (by default) means no default template.

Link copied to clipboard

Project description

Link copied to clipboard
open override var id: Id?

Project id. It appears in the web UI and is used in urls. If the project has a uuid specified, then the id can be changed at any time. If uuid is omitted, then TeamCity treats a project with a changed id as a new project, all data associated with the old project will be lost (e.g. investigations). Id can also be used by some settings, e.g. as a part of parameter reference. If you change the id, you should find all its occurrences in the current project and change them too. Id must be unique across all projects on the server. If id is missing, it will be generated from the class name (if the class is not from the jetbrains.buildServer.configs.kotlin package).

Link copied to clipboard

Project name

Link copied to clipboard

Id of the parent project, defines a place for this project in a project hierarchy. Can be omitted in relative context, when the parent project is the Root project, or a project is added to its parent using the subProject method. Otherwise, it is mandatory.

Link copied to clipboard

Specifies subprojects order, contains subproject ids.

Link copied to clipboard

Project uuid. TeamCity uses it to identify a project. If uuid changes, TeamCity considers it to be a new project. If uuid is missing, it is reconstructed from entity id. Uuid must be unique across all entities on the server.

Functions

Link copied to clipboard

Registers the specified buildType in this project.

fun buildType(init: BuildType.() -> Unit): BuildType

Registers a new buildType initialized with the specified block in this project.

Link copied to clipboard
fun cleanup(init: Cleanup.() -> Unit)

Configures project clean-up rules

Link copied to clipboard
open fun create(): Project

Creates an instance of this project via reflection using a no argument constructor, used during copying. Throws an error if this class doesn't have a default constructor. Subclasses can override it to create an instance without using a default constructor.

Link copied to clipboard
fun features(init: ProjectFeatures.() -> Unit)

Allows to specify project features

Link copied to clipboard
fun id(id: String)

Sets the id to the specified value. Type of the id depends on the context in which DSL is executed: it is RelativeId when DSL context is relative, otherwise it is AbsoluteId.

Link copied to clipboard

Configures project parameters

Link copied to clipboard
fun parentId(absoluteId: String)
Link copied to clipboard
Link copied to clipboard
fun subProject(subProject: Project)

Adds the specified subproject to this project

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

Adds a subproject to this project

Link copied to clipboard
fun subProjects(vararg projects: Project)

Sets subprojects of this project

Link copied to clipboard
fun template(template: Template)

Registers the specified template in this project

fun template(init: Template.() -> Unit): Template

Registers a new template initialized with the specified init block in this project

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun validate(consumer: ErrorConsumer)

Validates this object and reports found errors to the provided consumer

Link copied to clipboard
fun vcsRoot(root: VcsRoot)

Registers the specified VCS root in this project

fun vcsRoot(init: VcsRoot.() -> Unit): VcsRoot

Registers a new VCS root initialized with specified init build in this project