Skip to content

GitLab CI Kotlin DSLopensavvy.gitlab.ciArtifactsdotenv

dotenv

fun dotenv(path: String)

Collects environment variables from a dotenv file to pass to downstream jobs.

The dotenv file should contain key-value pairs in the format KEY=value. These variables become available as CI/CD variables in downstream jobs.

Example

val build by job {
    script {
        shell("echo 'BUILD_VERSION=1.2.3' build.env")
        shell("echo 'BUILD_URL=https://example.com' build.env")
    }

    artifacts {
        dotenv("build.env")
    }
}

val deploy by job {
    script {
        shell("echo 'Deploying version: $BUILD_VERSION'")
        shell("echo 'Build URL: $BUILD_URL'")
    }
    needs(build)
}

External resources