diff options
Diffstat (limited to 'app/models/concerns/enums/ci/pipeline.rb')
-rw-r--r-- | app/models/concerns/enums/ci/pipeline.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/app/models/concerns/enums/ci/pipeline.rb b/app/models/concerns/enums/ci/pipeline.rb new file mode 100644 index 00000000000..f1bc43a12d8 --- /dev/null +++ b/app/models/concerns/enums/ci/pipeline.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +module Enums + module Ci + module Pipeline + # Returns the `Hash` to use for creating the `failure_reason` enum for + # `Ci::Pipeline`. + def self.failure_reasons + { + unknown_failure: 0, + config_error: 1, + external_validation_failure: 2 + } + end + + # Returns the `Hash` to use for creating the `sources` enum for + # `Ci::Pipeline`. + def self.sources + { + unknown: nil, + push: 1, + web: 2, + trigger: 3, + schedule: 4, + api: 5, + external: 6, + # TODO: Rename `pipeline` to `cross_project_pipeline` in 13.0 + # https://gitlab.com/gitlab-org/gitlab/issues/195991 + pipeline: 7, + chat: 8, + webide: 9, + merge_request_event: 10, + external_pull_request_event: 11, + parent_pipeline: 12, + ondemand_dast_scan: 13 + } + end + + # Dangling sources are those events that generate pipelines for which + # we don't want to directly affect the ref CI status. + # - when a webide pipeline fails it does not change the ref CI status to failed + # - when a child pipeline (from parent_pipeline source) fails it affects its + # parent pipeline. It's up to the parent to affect the ref CI status + # - when an ondemand_dast_scan pipeline runs it is for testing purpose and should + # not affect the ref CI status. + def self.dangling_sources + sources.slice(:webide, :parent_pipeline, :ondemand_dast_scan) + end + + # CI sources are those pipeline events that affect the CI status of the ref + # they run for. By definition it excludes dangling pipelines. + def self.ci_sources + sources.except(*dangling_sources.keys) + end + + # Returns the `Hash` to use for creating the `config_sources` enum for + # `Ci::Pipeline`. + def self.config_sources + { + unknown_source: nil, + repository_source: 1, + auto_devops_source: 2, + webide_source: 3, + remote_source: 4, + external_project_source: 5, + bridge_source: 6, + parameter_source: 7 + } + end + end + end +end + +Enums::Ci::Pipeline.prepend_if_ee('EE::Enums::Ci::Pipeline') |