Job

open class Job : Validatable

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 {
id("build")
name = "Build Application"

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

Example. Job with dependencies and parameters

job {
id("build")
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.

Properties

Link copied to clipboard

Allow reuse

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

External job artifacts, artifact dependencies on build configurations outside this pipeline

Link copied to clipboard

Job name

Link copied to clipboard

Job output files configuration

Link copied to clipboard

Job parallelism determines parallelism level for this job

Link copied to clipboard

Job parameters

Link copied to clipboard

Job repositories

Link copied to clipboard

Job agent requirements

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
fun download(init: JobArtifacts.() -> Unit)

Adds an artifact dependency for the specified job. It allows depending on artifact files produced outside the Pipeline the job belongs to.

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

Configures job features

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 outputFiles(init: OutputFiles.() -> Unit)

Configures output files for the job. Allows specifying files to share with other jobs or publish as pipeline artifacts.

Link copied to clipboard

Configures job parameters

Link copied to clipboard

Configures VCS repositories for the job. Allows adding and configuring repositories specific to this job.

Link copied to clipboard
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.