Skip to content

GitLab CI Kotlin DSLopensavvy.gitlab.ciArtifactsrule

rule

fun rule(rule: When)

Specifies when to upload artifacts based on job result.

By default, artifacts are uploaded only when the job succeeds. Use this method to change when artifacts should be uploaded.

Example

val test by job {
    script {
        shell("run-tests")
    }

    artifacts {
        include("test-results/")
        rule(When.Always)  // Upload artifacts regardless of job result
    }
}

Example: upload on failure

artifacts {
    include("logs/")
    rule(When.OnFailure)  // Only upload when job fails
}

External resources