GitLab 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()

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!

Packages

Link copied to clipboard

Jobs, stages, dependencies and more: declaring a GitLab CI pipeline from Kotlin.

Link copied to clipboard

Easily use Gradle, Helm, Docker and more within your pipelines.

Link copied to clipboard

Methods related to declaring the script part of jobs.

Link copied to clipboard

Helpers to make the syntax nicer.

Link copied to clipboard

Lightweight embedded implementation of a Yaml serializer.