Git Lab CI Kotlin DSL
Generate your GitLab CI pipeline with Kotlin.
Configuration
First, install Kotlin. You can do so using your package manager of choice. Create a gitlab-ci.main.kts
file with the following content:
#!/usr/bin/env kotlin
@file:DependsOn("dev.opensavvy.gitlab:gitlab-ci-kotlin-jvm:VERSION-HERE") // See https://gitlab.com/opensavvy/automation/gitlab-ci.kt/-/releases
import opensavvy.gitlab.ci.*
import opensavvy.gitlab.ci.script.*
val pipeline = gitlabCi {
val test by stage()
val helloWorld by job(stage = test) {
script {
shell("echo 'Hello world'")
}
}
}
pipeline.println()
Content copied to clipboard
Allow execution for this file (on UNIX machines: chmod u+x gitlab-ci.main.kts
), then execute it (on UNIX machines: ./gitlab-ci.main.kts
). Congratulation, you have just written your first GitLab CI pipeline in Kotlin!