Module: Gitlab::RSpecMetricsExporter::Pipeline
Overview
Pipeline classification and CI pipeline id resolution.
Mixed into the metric builder to expose ‘pipeline_type` and `ci_pipeline_id` derived from CI environment variables. Methods are instance methods on the including class.
Constant Summary collapse
- STABLE_EE_BRANCH_REGEX =
/^[\d-]+-stable-ee$/
Instance Method Summary collapse
-
#ci_pipeline_id ⇒ Integer?
PARENT_PIPELINE_ID when set, otherwise CI_PIPELINE_ID.
-
#pipeline_type ⇒ String
GitLab pipeline classification, or “unknown”.
Methods included from Env
#env_fetch, #env_parse_int_or_nil, #env_present?
Instance Method Details
#ci_pipeline_id ⇒ Integer?
Returns PARENT_PIPELINE_ID when set, otherwise CI_PIPELINE_ID.
30 31 32 |
# File 'lib/gitlab/rspec_metrics_exporter/pipeline.rb', line 30 def ci_pipeline_id env_parse_int_or_nil(env_fetch("PARENT_PIPELINE_ID") || env_fetch("CI_PIPELINE_ID")) end |
#pipeline_type ⇒ String
Returns GitLab pipeline classification, or “unknown”.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/rspec_metrics_exporter/pipeline.rb', line 18 def pipeline_type return "default_branch_scheduled_pipeline" if default_branch? && env_fetch("SCHEDULE_TYPE") return "default_branch_pipeline" if default_branch? return "stable_branch_pipeline" if stable_ee_branch?("CI_COMMIT_REF_NAME") return "backport_merge_request_pipeline" if stable_ee_branch?("CI_MERGE_REQUEST_TARGET_BRANCH_NAME") return "merge_request_pipeline" if env_fetch("CI_MERGE_REQUEST_IID") return "downstream_pipeline" if env_fetch("CI_PIPELINE_SOURCE") == "pipeline" "unknown" end |