Skip to content

GitLab CI Kotlin DSLopensavvy.gitlab.ciJobbeforeScript

beforeScript

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

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

beforeScript has the same syntax as script.

The main usage of beforeScript is the ability to declare a script that will execute before all already-registered calls to script.

Example

val test by job {
    beforeScript {
        shell("apt upgrade")
    }

    script {
        shell("echo Hello world")
    }
}

External resources

Read more about the differences between script and beforeScript in the GitLab documentation.