All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.plugins.buildmetrics.gitlab.labels.GitlabCILabelsFactory.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC4
Show newest version
package ru.tinkoff.plugins.buildmetrics.gitlab.labels

import ru.tinkoff.plugins.buildmetrics.api.factories.Factory
import ru.tinkoff.plugins.buildmetrics.api.labels.Label
import ru.tinkoff.plugins.buildmetrics.utils.system.SystemEnv
import ru.tinkoff.plugins.buildmetrics.utils.system.SystemEnvImpl

/**
 * Labels:
 * - ci_commit_ref_name
 * - ci_job_id
 * - ci_job_name
 * - ci_job_stage
 * - ci_job_started_at
 * - ci_pipeline_created_at
 * - ci_pipeline_id
 * - ci_pipeline_source
 * - ci_project_name
 * - ci_project_url
 * - ci_runner_description
 * - ci_runner_version
 * - ci_merge_request_target_branch_name - if environment variable "CI_MERGE_REQUEST_ID" is defined
 *
 * @throws IllegalStateException if required environment variable is undefined
 */
// Can't use Gradle Providers API here because they are not Serializable
class GitlabCILabelsFactory(
    private val systemEnv: SystemEnv = SystemEnvImpl()
) : Factory.Labels {

    override fun create(): List> {
        return if (systemEnv.env("CI_MERGE_REQUEST_ID") != null) {
            gitlabLabels(systemEnv) + gitlabMergeRequestLabels(systemEnv)
        } else {
            gitlabLabels(systemEnv)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy