Skip to content

GitLab CI Kotlin DSLopensavvy.gitlab.ciJob

Job

class Job : YamlExport

A single execution step in a pipeline.

Jobs are instantiated using the job factory. See its documentation for more information.

Properties

name

val name: String

The name of this job, as it appears in the GitLab UI.

stage

val stage: Stage? = null

The Stage this job is a part of.

Functions

afterScript

fun afterScript(block: CommandDsl.() -> Unit)

Adds commands to execute after the main script of this job.

artifacts

fun artifacts(configuration: Artifacts.() -> Unit)

Declares paths that will be saved at the end of the job, and can later be consumed by other jobs in the same pipeline.

beforeScript

fun beforeScript(block: CommandDsl.() -> Unit)

Adds commands to execute before the main script of this job.

cache

fun cache(configuration: Cache.() -> Unit)

Declares paths that will be reused between different jobs, even if they are of different pipelines.

coverage

fun coverage(regex: String)

Declares a regular expression to configure how code coverage is extracted from the job output. The coverage is shown in the UI if at least one line of the job output matches regex.

dependsOn

fun dependsOn(job: Job, artifacts: Boolean = false, optional: Boolean = false)

This job will wait until job has terminated.

image

fun image(name: String, version: String = "latest", configuration: ContainerImage.() -> Unit = {})

The container image used to execute this job.

interruptible

fun interruptible(bool: Boolean)

Determines whether this job can be safely canceled after it has started.

publishChangelogToDiscord

publishChangelogToTelegram

retry

fun retry(max: Int, configuration: Retry.() -> Unit = {})

Configures how many times a job is retried if it fails. If not defined, defaults to 0 and jobs do not retry.

script

fun script(block: CommandDsl.() -> Unit)

Adds commands to execute in this job.

service

fun service(name: String, version: String = "latest", configuration: ContainerService.() -> Unit = {})

Additional container images used by this job.

tag

fun tag(name: String)

Adds a tag to this job.

toYaml

open override fun toYaml(): Yaml

Converts this object into a Yaml object.

useContainerRegistry

Logs in the current job to the GitLab Container Registry.

useDockerInDocker

fun Job.useDockerInDocker(dockerVersion: String = "20.10", dockerInDockerVersion: String = "-dind")

Configures the current job to use the docker command using Docker In Docker.

useGradle

fun Job.useGradle()

Enables the Gradle plugin.

variable

fun variable(name: String, value: String)

Declares an environment variable that will be available for the entire length of the job.