Job

open class Job : Validatable

Deprecated

Pipelines DSL is in development and should not be used. Breaking changes are expected.

Represents a job within a TeamCity pipeline.

A job is a unit of work in a pipeline that performs a specific task, such as building, testing, or deploying. Jobs can have dependencies on other jobs, allowing for complex workflows.

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

Job settings are grouped into blocks:

Example. Basic job with build steps

job("build") {
name = "Build Application"

steps {
gradle {
tasks = "clean build"
buildFile = "build.gradle"
}
}
}

Example. Job with dependencies and parameters

job("deploy") {
name = "Deploy Application"

params {
param("env.DEPLOY_ENV", "production")
}

steps {
script {
scriptContent = "deploy.sh"
}
}

dependency("build")
dependency("test")
}

See also

Constructors

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

Creates a job and initializes it with the specified init block.

constructor()

Types

Link copied to clipboard
class Dependency(val job: String, val files: List<String>? = null)

Represents a dependency on another job.

Link copied to clipboard
class FilePublication(val path: String, val publishArtifact: Boolean = false, val shareWithJobs: Boolean = true)

Represents a file publication configuration.

Link copied to clipboard
class Repository(val root: IdOwner, val enabled: Boolean = true, val path: String? = null, val branch: String? = null)

Represents a repository used by the job.

Properties

Link copied to clipboard

Allow reuse

Link copied to clipboard
Link copied to clipboard

Enable dependency cache optimization

Link copied to clipboard
Link copied to clipboard
var id: String
Link copied to clipboard
Link copied to clipboard

Job name

Link copied to clipboard

Job output parameters

Link copied to clipboard

Job parallelism determines parallelism level for this job

Link copied to clipboard

Job parameters

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun create(): Job

Creates an instance of this job 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 dependency(job: Job)

Adds a dependency on the specified job

fun dependency(jobId: String)

Adds a dependency on a job with the specified id.

fun dependency(job: Job, files: List<String>)

Adds a dependency on the specified job with a list of files

fun dependency(jobId: String, files: List<String>)

Adds a dependency on a job with the specified id and a list of files.

Link copied to clipboard

Adds a file publication with the specified path.

fun filePublication(path: String, publishArtifact: Boolean, shareWithJobs: Boolean)

Adds a file publication with the specified path and options.

Link copied to clipboard
fun id(id: String)

Sets the relative part of the id to the specified value.

Link copied to clipboard

Adds the specified integration to the job.

fun integration(type: String, id: String)

Adds an integration to the job.

Link copied to clipboard
fun outputParam(name: String, value: String)

Adds an output parameter to the job. Output parameters can be used by other jobs that depend on this job.

Link copied to clipboard

Configures output parameters, i.e. the parameters which will be visible to jobs depending on this job.

Link copied to clipboard

Configures job parameters

Link copied to clipboard
fun repository(id: Id)
fun repository(id: Id, path: String? = null, branch: String? = null)

Adds a repository with the specified id

fun repository(root: IdOwner)
fun repository(root: IdOwner, path: String? = null, branch: String? = null)

Adds a repository with the specified IdOwner

Link copied to clipboard
fun steps(init: PipelineSteps.() -> Unit)

Configures job steps

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

Validates the job configuration. Checks that all required properties are set and all components are valid.